Re: Using shell commands in an application
Re: Using shell commands in an application
- Subject: Re: Using shell commands in an application
- From: Cryx <email@hidden>
- Date: Fri, 5 Jul 2002 03:26:36 -0500
Seems like a questionable design. I'd have the script chdir to the
dirname of $0. Anyhow, here's some good and bad advice.
Bad advice:
Add an argument of "-c". Combine your two existing arguments with a
semicolon into one argument.
Allowing the shell to mangle your commands is not a terrible idea. The
target script or folder name may have shell metachars which will cause
unpredictable results (remember the iTunes installer fiasco?). Always
avoid the shell.
Good advice:
Use setCurrentDirectoryPath: instead of cd. Use the actual script in
setLaunchPath. Launch the task. It's that simple.
On Friday, July 5, 2002, at 03:02 AM, Arthur VIGAN wrote:
Hi,
My application needs to use some shells commands to works: the aim is to
launch a shell script, but for that script to work, I have to be in the
directory where it is (I can't use /Users/arthur/aFolder/mySript to
execute). In the terminale, this would be:
% cd /Users/arthur/aFolder
% ./myScript
In my app I used the following, but it desn't work:
[myTask setLaunchPath:@"/bin/tcsh"];
[arguments addObject:[[NSString stringWithString:@"cd ~/aFolder"]
stringByExpandingTildeInPath]];
[arguments addObject:[NSString stringWithString:@"./myScript"]];
[myTask setArguments:arguments];
[myTask launch];
Where is the problem?
Thanks in advance.
Arthur
_______________________________________________
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.
Daryn
_______________________________________________
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.