NSTask Says: launch path not accessible
NSTask Says: launch path not accessible
- Subject: NSTask Says: launch path not accessible
- From: Adam <email@hidden>
- Date: Sun, 24 Apr 2005 15:18:09 -0400
I am trying to use NSTask to call a command line program from my cocoa
app. When running the app from xcode, either in deployment or
developmebt build style, the default CurrentDirectoryPath for an NSTask
is the build folder of the project. If I put my command line app in the
build folder and launch my NSTask everything works great. However, when
an app is built and launched outside of xcode the default
CurrentDirectoryPath for an NSTask is the root of the hard drive. Same
positive results here, if I put a copy of my command line app on the
root of the hard drive all works fine.
However, I would like to hide my command line app from the user. I
placed it inside the resources folder of the app bundle and when I set
the NSTask's CurrentDirectoryPath to be the Resource folder in the app
bundle, and place my command line tool is this folder I get an error
"launch path not accessible". In fact I have tried several experiments.
If I put the command line app ANYWHERE other then the default
CurrentDirectoryPath for nstask and try to set the CurrentDirectoryPath
to this new location I get the same error when I launch the task.
If I have confirmed that my paths are correct, the command line app is
in the location that I am passing to setCurrentDirectoryPath, why would
I get "launch path not accessible" in every location I try other then
the default.
NSBundle *thisBundle = [NSBundle bundleForClass:[self class]];
NSString *pathToModcapEditorCmdline = [thisBundle resourcePath];
NSPipe *pipe=[[NSPipe alloc] init];
NSFileHandle *handle;
NSString *output;
NSTask *ModcapEditorCmdlineTask = [[NSTask alloc] init];
[ModcapEditorCmdlineTask setLaunchPath:@"ModcapEditorCmdline"];
[ModcapEditorCmdlineTask setCurrentDirectoryPath:
pathToModcapEditorCmdline];
[ModcapEditorCmdlineTask setArguments:[NSArray
arrayWithObjects:inputFilePath,nil]];
[ModcapEditorCmdlineTask setStandardOutput:pipe];
handle=[pipe fileHandleForReading];
[ModcapEditorCmdlineTask launch];
output = [[NSString alloc] initWithData:[handle readDataToEndOfFile]
encoding:NSASCIIStringEncoding];
[outputTextView setString:output];
[ModcapEditorCmdlineTask release];
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden