如何捕获 iPhone 上的系统统计数据?
我正在尝试编写一个 iPhone 应用程序来模仿 *nix 系统上可用的顶级系统实用程序。似乎 system() 和/或 popen() 应该使我能够捕获在 iphone 上执行的系统命令的输出。但是,以下代码没有为 popen 或 system 提供任何输出。还有其他方法可以获取此信息吗? iPhone 上的 iStats 应用程序似乎能够捕捉到这一点,我假设它自从出现在应用程序商店以来就受到了苹果公司的祝福。无论如何,我们将非常感谢任何帮助!
FILE *f = popen("ps", "r");
StringPtr *buf1 = malloc(60);
fread(buf1, 0, sizeof(buf1), f);
NSLog(@"system = %s",buf1 );
system('ls /');
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 /');
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
据我所知,您尝试运行的命令不是在普通 iPhone 上运行,而是在越狱的 iPhone 上运行。这就是它不起作用的原因。
iStats 收集您有权访问的 Mac 计算机的统计信息,而不是您本地的 iPhone。
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.