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

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

问题描述

我有一个 exec 命令,它的行为与通过 Penguinet 提供给 linux 的相同命令不同.

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

将命令直接放入命令行时,我在日志文件中看到大约 100 个条目.但是,当我访问具有 exec() 命令的 PHP 页面时,我只看到 1 个.并且它的格式正确.为什么 PHP 只显示一个结果?如何让它显示文件的全部内容?

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?

似乎只返回最后一行.我该如何改变?

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

推荐答案

试试这个:

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

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

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