MetalSmith Posted February 21, 2009 Share Posted February 21, 2009 Ok I am desperate now. I am starting to think this can't be done. All I need is to have a php script open up Putty.exe run a command on a local Linux box and close out. I am using an XP machine with Apache on it. I have posted this problem before and had some good direction but every attempt gives the same result. Run it under the CLI works fine, Hit it on the Apache and it hangs. Here is my lastest attempt: <?php exec('php -q "C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\aastra\awa-det\conference\reload.php"', $output); print_r ($output); ?> BTW I don't know what the -q does and the print output is irrelevant I just have it in there for trying to see whats going on. This script will call on this script: <?php exec('"c:\program files\apache software foundation\apache2.2\htdocs\putty.exe" -ssh [email protected] -pw (password) -m reload.sh'); ?> The reload.sh file has this in it: mkdir "New Folder" I have checked with the permissions in Apache and everything is set to Allow so I know that's not the problem. I must note that when I do hit it from the Apache I hear the windows exclamation sound in the background if that would give a clue to someone. Does Apache need its own account to run an exe file on windows? If someone can see what I am doing wrong I swear I will send you a check for $50.00!!!! If I can get this to work it will be pretty cool for what I am doing at work. Quote Link to comment https://forums.phpfreaks.com/topic/146263-omg-wtf-exec/ Share on other sites More sharing options...
MetalSmith Posted February 21, 2009 Author Share Posted February 21, 2009 Well I also tried this. The browser does not hang anymore but notepad.exe does not execute. CLI works perfect again, SHOCKER!! <?php $WshShell = new COM("WScript.Shell"); $oExec = $WshShell->Run("notepad.exe", 3, false); ?> Quote Link to comment https://forums.phpfreaks.com/topic/146263-omg-wtf-exec/#findComment-767937 Share on other sites More sharing options...
MetalSmith Posted February 21, 2009 Author Share Posted February 21, 2009 Well I have researched this for a few days now. My conclusion is that Apache on Windows is preventing this action from happening. The php code is not the problem its the limitations of the Apache web sever or some sort of security feature that can't be worked around. Bummer Quote Link to comment https://forums.phpfreaks.com/topic/146263-omg-wtf-exec/#findComment-767993 Share on other sites More sharing options...
MetalSmith Posted February 22, 2009 Author Share Posted February 22, 2009 WAAAHHOOOO!!!! I found the answer!!! Well it looks like this thread is turning into my own blog! but in my exhausting few days of google searching I did find a thread somewhere where a guy mentioned to have the Apache service running on windows changed to "Allow service to interact with desktop". To find this open up services and find the Apache service and under the login tab you will find it. I must also mention you MUST!! restart the PC. Restarting the service doesn't cut it. Aslo big thanks to the guy who came up with the method of running the script like I have below: <?php $WshShell = new COM("WScript.Shell"); $oExec = $WshShell->Run('"C:\Program Files\putty.exe" -ssh [email protected] -pw password -m "C:\Program Files\reload.sh"'); ?> having an exec() in a script and hitting with the webserver will cause it to hang. The script above is the work around. And for those of you interested in my script it will open a session with a local Linux box login and run any commands you want. You list the commands you want in a file called whatever.sh that's it! Good Luck! Quote Link to comment https://forums.phpfreaks.com/topic/146263-omg-wtf-exec/#findComment-768529 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.