views:

162

answers:

1

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 /');
A: 

AFAIK the commands you are trying to run are not on a vanilla iphone, but definitely on a jailbroken one. That is why it's not working.

iStats gathers statistics for mac machines to which you have access, not your local iphone.

John Smith
@John Smith there is an iStat app for the iphone, check it out in the app store!!
ennuikiller