php exec返回的结果比直接进入命令行的结果少 [英] php exec returns less results than entering into command line directly

查看:70
本文介绍了php exec返回的结果比直接进入命令行的结果少的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个执行命令,其行为与通过Penguinet给予linux的命令不同。


$ b

  $ res = exec ('cd / mnt / mydirectory /; zcat log_file.gz'); 
echo $ res

将命令直接放入命令行时,日志文件中的条目。但是,当我访问具有 exec()命令的PHP页面时,我只能看到1.它的格式正确。为什么PHP只显示一个结果?
$ b

编辑:

看起来这只是只返回最后一行。

解决方案

试试这个:

  exec('cd / mnt / mydirectory /; zcat log_file.gz',$ res); 
print_r($ res);


I have an exec command that is behaving differently than the same command given to linux through Penguinet.

 $res = exec('cd /mnt/mydirectory/; zcat log_file.gz');
 echo $res

When putting the commands directly into the command line, I see about 100 entries in the log file. However when I access the PHP page that has the exec() command, I see only 1. And it is formatted correctly. Why does PHP show me only one result? How can I make it show the entire contents of the file?

EDIT:

Seems this is only returning only the last line. How can I change that?

解决方案

try this:

exec('cd /mnt/mydirectory/; zcat log_file.gz', $res);
print_r($res);

这篇关于php exec返回的结果比直接进入命令行的结果少的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆