Searching PATH environment var for executables prior to NSTask invocation
Searching PATH environment var for executables prior to NSTask invocation
- Subject: Searching PATH environment var for executables prior to NSTask invocation
- From: Leigh Smith <email@hidden>
- Date: Mon, 3 Feb 2003 20:08:52 -0500
I have NSTask working fine with a hard coded path to my binary, however
I'd like to not enforce the location of the command line tool (since it
isn't a system supplied tool and can be installed in a number of
places). In short, I'd like the PATH environment variable searching
that execve() provides with NSTask, similar to the use of "which".
While NSBundle would seem to do the job if the tool resided within an
application, in this case, the binary may sit in /usr/bin,
/usr/local/bin, /sw/bin (fink), /fink/bin (for perverse fink
installations), or /just/about/anywhere.
Short of writing my own routine to obtain PATH from the environment
NSDictionary obtained from NSProcessInfo, split it apart at each ':'
character and use NSFileManager to test the location of each
concatentation of candidate directory and executable name for
executability, does anyone have a simpler or pre-existing means? Other
than running "which" using NSTask to obtain a result as an NSString of
course!
Thanks
--
Leigh Smith
mailto:email@hidden
http://www.leighsmith.com
_______________________________________________
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.