使用php执行powershell脚本时挂起

时间:2015-08-07 19:09:29

标签: php powershell exec shell-exec

使用$out = shell_exec('powershell.exe -command C:\xampp\htdocs\web\ping.ps1 < NUL'); echo $out;

运行powershell脚本时

它挂起并注意到,页面只是继续加载, 这是我的简单剧本

ping 8.8.8.8 -t

我在powershell中使用了这个命令,以便首先允许执行脚本,

Set-ExecutionPolicy RemoteSigned -Scope CurrentUser

但没有任何改变。 我需要帮助,如何使用php执行powershell脚本?

1 个答案:

答案 0 :(得分:0)

这种情况正在发生,因为标记-t为命令提示符提供了继续执行ping操作的命令,直到它被中断为止。

常量加载是php执行power shell脚本并等待所述脚本在继续之前停止执行。因为您的电源shell脚本永远不会停止,直到您离开页面。它会不断加载

因此中断将是php内存最大化和失败。或者用户离开停止执行的页面。请查看

man page

我建议使用计数,然后在执行后捕获输入

相关问题