Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

swhirsch

macrumors newbie
Original poster
Sep 4, 2009
1
0
I'm trying to write an iphone app that would mimic the top system utility available on *nix systems. It seems as if system() and/or popen() should enable me to capture output from system commands executed on the iphone. However, the following code gives no output for either popen or system. Is there some other way of getting this info. The iStats app on the iphone seems to be able to capture this and I'm assuming its blessed by Apple since its in the app store. In any event any help would be very much appreciated!!

FILE *f = popen("ps", "r");
StringPtr *buf1 = malloc(60);
fread(buf1, 0, sizeof(buf1), f);
NSLog(@"system = %s",buf1 );
system('ls /');
 
I do not think there is a way to execute system commands with an unjailbroken iPhone. That said, your system call at the bottom can be achieved by NSFileManager.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.