Jump to content

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.