PHP运行shell脚本


php run shell script

我正在尝试从php前端运行shell脚本

这里是shell文件(运行.sh chmod到777)

#!/bin/bash
wget -O index.html http://markets.usatoday.com/custom/usatoday-com/html-mktscreener.asp
python hw7-9.py index.html 
echo "done";

这是php前端

<?php
   $output = shell_exec("run.sh");
   echo "<pre>$output</pre>";
?>

但是php页面除了

什么都没有返回
<pre></pre>

您是否尝试过在PHP脚本的顶部执行error_reporting(-1); ?可能您的服务器上禁用了shell_exec

你愿意试试吗$output = shell_exec("sh run.sh");

检查php/web服务器实际作为什么用户运行-例如:"www-user"可能没有任何权限去做脚本试图做的事情(并且有很好的理由)。