I want to run a terminal command from my objective-c project.
When I run it from the teminal I use :
cd /Users/user/Desktop/project/;ant release
now I used this in the Objective-C project:
NSTask *task = [NSTask new];
[task setLaunchPath:@"cd /Users/user/Desktop/project/;ant"];
[task setArguments:[NSArray arrayWithObjects:@"release", nil]];
NSPipe *pipe = [NSPipe pipe];
[task setStandardOutput:pipe];
[task launch];
NSData *data = [[pipe fileHandleForReading] readDataToEndOfFile];
[task waitUntilExit];
[task release];
NSString *string = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
NSLog (@"got\n%@", string);
[string release];
and after [task launch]; I get error:
launch path not accessible
Edit
I tried to use this command for check:
[task setCurrentDirectoryPath:@"/Users/user/Desktop/Czech/"];
[task setLaunchPath:@"/bin/ls"];
and it still give me a warning :
working directory doesn't exist.
You need to set the working directory in a different way:
Then change your
setLaunchPath:call to point to the location of the actual executable: