andrewdav Posted March 24, 2010 Share Posted March 24, 2010 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 Quote Link to comment https://forums.phpfreaks.com/topic/196361-shell_exec-hangs-page/ Share on other sites More sharing options...
premiso Posted March 24, 2010 Share Posted March 24, 2010 Have you tried running the command via the cmd.exe interface? Does it work properly there or does it hang as well? Chances are it is expecting more input or "pause's" after it executes which is why it would hang. Quote Link to comment https://forums.phpfreaks.com/topic/196361-shell_exec-hangs-page/#findComment-1031052 Share on other sites More sharing options...
andrewdav Posted March 24, 2010 Author Share Posted March 24, 2010 it works from the command prompt and outputs as expected, so the command is correct. Quote Link to comment https://forums.phpfreaks.com/topic/196361-shell_exec-hangs-page/#findComment-1031055 Share on other sites More sharing options...
andrewdav Posted March 24, 2010 Author Share Posted March 24, 2010 the same thing happens with this command $output = shell_exec("cmd"); i'd expect to see Microsoft Windows XP [Version 5.1.2600] © Copyright 1985-2001 Microsoft Corp. C:\> return to $output - but this doesn't happen, just hangs the browser. Quote Link to comment https://forums.phpfreaks.com/topic/196361-shell_exec-hangs-page/#findComment-1031069 Share on other sites More sharing options...
premiso Posted March 24, 2010 Share Posted March 24, 2010 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? Quote Link to comment https://forums.phpfreaks.com/topic/196361-shell_exec-hangs-page/#findComment-1031092 Share on other sites More sharing options...
slowfib Posted August 18, 2010 Share Posted August 18, 2010 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. Quote Link to comment https://forums.phpfreaks.com/topic/196361-shell_exec-hangs-page/#findComment-1100983 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.