Jump to content

shell_exec hangs page...


andrewdav

Recommended Posts

Hello all,

 

I am using a shell_exec command like the one below:

 

$output = shell_exec('c:\powershell\powershell.exe get-service');
echo($output);

 

However, when launching the page, the browser will hang with the hour-glass. If i end the powershell.exe process on the web server via task manager, the browser then returns the expected output.

 

Any idea why this is? Other commands, like ipconfig return the correct output and the browser displays "Done" in the bottom left.

 

Any help appreciated.

 

Andrew

 

Link to comment
https://forums.phpfreaks.com/topic/196361-shell_exec-hangs-page/
Share on other sites

The reason it hangs is it is expecting input, without the exit command being issued the command prompt is just going to sit there waiting for input, as that is what it does.

 

So if you were able to pass "exit" to that command prompt, it would un-hang the browser as it would kill the cmd process. Does that make sense?

  • 4 months later...

I'm experiencing this same problem too, andrewdav, did you ever solve this?

 

My code:

$output = array();
exec("powershell get-service", $output);
exec("exit");
print_r($output);

 

 

My browser hangs until I goto Task Manager on the machine and kill Powershell.exe, then my results are returned.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.