简体   繁体   English

php运行shell脚本

[英]php run shell script

I'm trying to run a shell script from a php frontend 我正在尝试从php前端运行shell脚本

heres the shell file (run.sh chmod to 777) 下面是shell文件(run.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";

Heres the php front end 继承了php前端

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

But it php page doesn't return anything except 但它的php页面除了返回任何内容

<pre></pre>

Have you tried doing error_reporting(-1); 你试过做error_reporting(-1); at the top of your PHP script. 在PHP脚本的顶部。 Likely shell_exec is disabled on your server. 可能在您的服务器上禁用了shell_exec

你会尝试$ output = shell_exec(“sh run.sh”);

检查php / web服务器实际运行的用户 - 例如“www-user”可能没有任何权限来执行脚本尝试执行的操作(并且有充分的理由)。

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

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