Browser Freezes Running PHP Powershell Runs

I am trying to run a simple PHP that runs a powershell script, if I use this code, I get the results in a command window, but I get an empty pool in the browser:

<?php exec("powershell C:\\Inetpub\\wwwroot\\my_shell.ps1 < NUL", $output); echo "<pre>"; print_r($output); echo "</pre>"; ?> 

I believe that NUL will discard the output, however it works in the browser that found it on [this Fourm] [1]

If I use this code without NUL , I will get the results in the command window, but if I run the script in the browser, it will continue loading forever and it will never give me the results:

 exec("powershell C:\\Inetpub\\wwwroot\\emsrDev\\manual_shell.ps1", $output); 

The same results if I do it as follows:

 $output = shell_exec("powershell C:\\Inetpub\\wwwroot\\emsrDev\\manual_shell.ps1"); 

The power shell script works fine if I run it independently:

 $cmd = "cmd.exe"; &$cmd "/C echo update tasks set last='manual' where id='8'; | sqlplus vvv/ www@xxx "; 

So I need to do this in the browser and get the output.

+4
source share
1 answer

The powershell process does not end, which causes the browser to freeze. Add a script to the end

following:
 Stop-Process -processname powershell* 
+1
source

Source: https://habr.com/ru/post/1411622/


All Articles