我正在尝试运行一个运行Power
Shell脚本的简单
PHP,
如果我使用这段代码,我会在命令窗口中得到结果,但是我在浏览器中得到一个空数组:
exec("powershell C:\\Inetpub\\wwwroot\\my_shell.ps1 < NUL", $output);
echo "
";
print_r($output);
echo "
";?>
我相信NUL将丢弃输出,但是它在浏览器中发现了它[这个Fourm] [1]
如果我使用这个代码,没有NUL,我会在命令窗口中得到结果,但如果我在浏览器中运行脚本将继续加载,它永远不会给我任何结果:
exec("powershell C:\\Inetpub\\wwwroot\\emsrDev\\manual_shell.ps1", $output);
如果我这样做,结果相同:
$output = shell_exec("powershell C:\\Inetpub\\wwwroot\\emsrDev\\manual_shell.ps1");
如果我独立运行powershell脚本运行正常:
$cmd = "cmd.exe";
&$cmd "/C echo update tasks set last='manual' where id='8'; | sqlplus vvv/www@xxx";
所以我需要在浏览器中执行此操作并获取输出.