NSTask *task = [[NSTask alloc] init];
task.launchPath = @"/usr/bin/ruby";
NSArray *arguments = [NSArray arrayWithObjects:@"arg1", @"arg2", nil];
task.arguments = arguments;
NSPipe *pipe = [NSPipe pipe];
task.standardOutput = pipe;
NSFileHandle *file = [pipe fileHandleForReading];
[task launch];
NSData *data = [file readDataToEndOfFile];
NSString *retval = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
via http://stackoverflow.com/questions/412562/execute-a-terminal-command-from-a-cocoa-app