EDIT 1
This code is currently printing to the console. What I would like to do is get the data in a string (and stop the data going to the console) so I can parse it for specific information. I hope my question is clear. Please ask for clarification if needed :)
EDIT 2
Another alternative could be to print it to a file and then I could read from that file afterwards. Just don't want it printing to the console :)
Hello Lovely Intelligent Computer People!
Any help with this would be great.
So far I'm using NSTask to spawn a process:
NSTask *top_task;
top_task = [[NSTask alloc] init];
[top_task setLaunchPath: @"/usr/bin/top"];
NSArray *arguments;
arguments = [NSArray arrayWithObjects: @"-s", @"1",@"-l",@"3600",@"-stats",@"pid,cpu,time,command", nil];
[top_task setArguments: arguments];
NSPipe *pipe;
pipe = [NSPipe pipe];
[top_task setStandardInput:[NSPipe pipe]];
NSFileHandle *file;
file = [pipe fileHandleForReading];
[top_task launch];
Now, how do I grab the resulting information, let us say, in the form of an NSString?
Thanks for all and any help! :)