• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Executing a perl script from cocoa - ObjC
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

References: 
 >Executing a perl script from cocoa - ObjC (From: "Ramakrishna Kondapalli" <email@hidden>)
 >Re: Executing a perl script from cocoa - ObjC (From: Bjoern Kriews <email@hidden>)

  • Prev by Date: Re: Versioning
  • Next by Date: class cluster making: easy/lazy way to keep counterpart methods in sync?
  • Previous by thread: Re: Executing a perl script from cocoa - ObjC
  • Next by thread: Re: Executing a perl script from cocoa - ObjC
  • Index(es):
    • Date
    • Thread