Re: Executing a perl script from cocoa - ObjC
Re: Executing a perl script from cocoa - ObjC
- Subject: Re: Executing a perl script from cocoa - ObjC
- From: Daryn <email@hidden>
- Date: Sat, 21 Feb 2004 15:21:33 -0600
On Feb 20, 2004, at 7:01 AM, Bjoern Kriews wrote:
>
On 20.02.2004, at 12:12, Ramakrishna Kondapalli wrote:
>
>
> I want to execute a Perl script (For Ex. ./Users/usr1/per1.sh
>
> <file_name>) from my cocoa - ObjC code and put the output in a file.
>
> How
>
> can I do this?
>
>
>
> Thanks & Regards,
>
>
simplest way (works in every C program):
>
>
#include <stdlib.h>
>
system("any shell command here > somefile");
>
>
For a more Cocoaish solution, take a look at NSTask,
>
there are various examples on the net, one by Apple,
>
called Moriarity if I recall correctly,
>
cocoadevcentral.com has something about it and
>
the book "Cocoa Programming" explains it pretty well.
System is convenient, but is also incredible dangerous. Most
non-alphanumeric characters are shell metacharacters that perform
special behaviors. If any of these characters exist in a filename,
unexpected results will occur. Trying to properly quote the arguments
is a pain. Do not use system() in applications.
I'd recommend using either pipe/fork/exec, or use NSTask with an
explicit argument list.
[demime 0.98b removed an attachment of type application/pkcs7-signature which had a name of smime.p7s]
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.