简体   繁体   English

php exec 返回的结果比直接进入命令行少

[英]php exec returns less results than entering into command line directly

I have an exec command that is behaving differently than the same command given to linux through Penguinet.我有一个 exec 命令,它的行为与通过 Penguinet 提供给 linux 的相同命令不同。

 $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.将命令直接放入命令行时,我在日志文件中看到大约 100 个条目。 However when I access the PHP page that has the exec() command, I see only 1. And it is formatted correctly.但是,当我访问具有exec()命令的 PHP 页面时,我只看到 1。并且它的格式正确。 Why does PHP show me only one result?为什么 PHP 只显示一个结果? 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);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM