问题:php如何执行top命令讲结果写入文件txt
描述:phpsshlinux
做个项目 需要用到php执行top 命令,
$test = "top -b -n1 >/home/kong/top.txt";
exec($test,$array); //执行命令
system($test);
popen($test, $mode);
这三种方法均不能将结果输入文件,
$handle = popen('top -b -n1 >/home/kong/top.txt', 'r');
$filename="/home/kong/workspace/demo/result.txt";
$wstream = fopen($filename, 'w') or die("打不开");
$read = fread($handle, 2096);
fwrite($wstream, $read) or die("写入失败!");
这样也不行,请大神们指导,怎么才能行!!!
解决方案1: php不是做这个的,你应该用shell
- 明星图片
- 相关文章
-
联系邮箱:mxgf168#qq.com(#改为@)