Re: command line tool paths
Re: command line tool paths
- Subject: Re: command line tool paths
- From: John Goodman <email@hidden>
- Date: Wed, 7 Nov 2007 16:08:29 -0500
Well that nailed it; thanks Chris. If I'm not overstaying my welcome, can you indulge me with a follow-up question?Ultimately, I'll be running this command line tool from a Cocoa app using an NSTask object. Is there a way for my Cocoa app to change the working directory before calling the NSTask? (Or is this a question for the Cocoa list?)
Thanks again for getting me this far. I can probably stumble through the rest if you don't have a quick answer.
John
On Nov 7, 2007, at 3:53 PM, Chris Espinosa wrote: On Nov 7, 2007, at 12:20 PM, John Goodman wrote: I'm using Xcode (2.4.1) to compile a command line tool, using some existing Linux code.
The code references a configuration file containing file paths to additional configuration data. The paths in the configuration file are all specified relative to the executable.
When I run the code from Xcode, all these relative paths work to find the appropriate files. When I run the code from the Terminal, the files are not found unless I use absolute paths.
What is Xcode doing to enable the use of relative paths? Can I do something similar to make the relative paths effective running outside of Xcode?
I should add (if it isn't already obvious) that my experience with the Terminal and command line tools approaches zero.
Thanks for your suggestions.
Xcode gives you the choice, when launching an executable, of setting the working directory to:
- the project directory - the build product directory - an arbitrary directory of your choice
The Shell sets the working directory to the current directory when the command is executed, and the initial working directory is your home directory.
The solution is in Terminal to cd (change directory) to the directory containing your executable, then execute it with ./<executablename> . (The ./ is required to prevent people from spoofing command-line builtins with malware executables in user's home directories)
Chris
|
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden