を使用しNSTask
ます。ドキュメントとQuartz Composer CommandLineToolをご覧ください。
+ (void) executeShellCommandAsynchronously:(NSString*)command
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
NSTask *task = [[[NSTask alloc] init] autorelease];
[task setLaunchPath: @"/bin/sh"]; //we are launching sh, it is wha will process command for us
[task setStandardInput:[NSFileHandle fileHandleWithNullDevice]]; //stdin is directed to /dev/null
NSArray *args = [NSArray arrayWithObjects: @"-c", //-c tells sh to execute commands from the next argument
command, //sh will read and execute the commands in this string.
nil];
[task setArguments: args];
[task launch];
[command release];
[pool release];
return;
}