How to capture system stats on the iPhone?

Discussion in 'iOS Programming' started by swhirsch, Sep 4, 2009.

  1. swhirsch macrumors newbie

    Sep 4, 2009
    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 /');
  2. jaikob macrumors 6502


    Jul 1, 2008
    Freeland, MI
    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.

Share This Page