• 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
Searching PATH environment var for executables prior to NSTask invocation
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

  • Prev by Date: current user if started from /Library/StartupItems
  • Next by Date: Re: current user if started from /Library/StartupItems
  • Previous by thread: Re: Hidden Objects
  • Next by thread: Floating point problem???
  • Index(es):
    • Date
    • Thread