NSTask's real-time output
I have a PHP script which has mutliple sleep() commands. I would like to execute it in my application with NSTask . My script looks like this: echo "first\n"; sleep(1); echo "second\n"; sleep(1); echo "third\n"; I can execute my task asynchronously using notifications: - (void)awakeFromNib { NSTask *task = [[NSTask alloc] init]; [task setLaunchPath: @"/usr/bin/php"]; NSArray *arguments; arguments = [NSArray arrayWithObjects: @"-r", @"echo \"first\n\"; sleep(1); echo \"second\n\"; sleep(1); echo \"third\n\";", nil]; [task setArguments: arguments]; NSPipe *p = [NSPipe pipe]; [task