shell_exec()
:
我正在做一个使用 shell_exec()
函数的 PHP 站点,如下所示:
$file = "upload/" . $_FILES["file"]["name"];
$output = shell_exec("leaf $file");
echo "<pre>$output</pre>";
其中 leaf 是一个程序,它位于我的脚本的同一目录中,但是当我尝试在服务器上运行该脚本时,我什么也没得到。
exec()
:
如果我尝试像这样使用 exec()
:
exec("sh " . getcwd() . "leaf -h", &$output);
echo "<pre>";
print_r(&$output);
echo "</pre>";
我明白了:
Array ( )
如果我做同样的事情,但使用 echo
而不是 print_r
,我只会得到这个:Array
我能做什么?
最佳答案
您是否尝试过在“叶”引用中使用完整路径?
$output = shell_exec("/var/local/leaf $file");
关于php - shell_exec() 和 exec() 不显示输出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2775431/