Re: Calling a unix command from Cocoa ?
Re: Calling a unix command from Cocoa ?
- Subject: Re: Calling a unix command from Cocoa ?
- From: Chris Parker <email@hidden>
- Date: Fri, 8 Nov 2002 15:30:56 -0800
Hi Robert,
On Friday, November 8, 2002, at 10:59 AM, Robert Miller wrote:
Can anyone tell me if it is possible to call a unix command from
within a running Cocoa application ? (in my case flex and bison) ?
And if so, what's the secret ? For some reason there doesn't seem to
be any documentation or examples available on this topic unless I'm
missing something which is entirely possible..
I suspect you're looking for NSTask, in the Foundation framework. Docs
available at
http://developer.apple.com/techpubs/macosx/Cocoa/Reference/Foundation/
ObjC_classic/Classes/NSTask.html
From there:
"Using NSTask, your program can run another program as a subprocess and
can monitor that program's execution. NSTask creates a separate
executable entity; it differs from NSThread in that it does not share
memory space with the process that creates it."
You can do various things w.r.t. launching the task, including setting
various command line options, environment variables, etc. An example
using NSTask is available at
http://developer.apple.com/samplecode/Sample_Code/Cocoa/Moriarity.htm
which wraps the locate(1) command.
.chris
--
Chris Parker
Cocoa Frameworks Engineer
Apple Computer, Inc.
_______________________________________________
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.