peeps Posted March 11, 2007 Share Posted March 11, 2007 I want to be able to start a console program on the computer running my WAMP server via a php page. I want the program to run and stay running on the machine not close when the page is closed. I have tried system() and ecec() and have not been able to get them to work the way I want them to. As of right now I don't care Linux or windows, but I would like a solution for windows. Link to comment https://forums.phpfreaks.com/topic/42233-solved-start-a-program-via-php-page/ Share on other sites More sharing options...
s0c0 Posted March 11, 2007 Share Posted March 11, 2007 Try this: http://www.phpfreaks.com/phpmanual/page/function.exec.html Maybe give us a little bit more information on the program you are trying to run and how you are calling it. I have never used the exec function, but I see no reason why it should not work! Link to comment https://forums.phpfreaks.com/topic/42233-solved-start-a-program-via-php-page/#findComment-205012 Share on other sites More sharing options...
s0c0 Posted March 11, 2007 Share Posted March 11, 2007 I was able to do a few very basic things with this function in 2-3 minutes and like I said I've never used it before. The first basic thing I did was this (btw I'm running debian linux): $hi = exec('echo hi'); echo $hi; On the linux bash shell echo is a valid command it just returns what you put after echo. So my php script sent that to the shell and it put the output in the $hi variable. Next I tried something a bit more useful. $pingit = exec('ping google.com -c 1'); echo $pingit; This returned the very last line of the shell output which was "rtt min/avg/max/mdev = 73.977/73.977/73.977/0.000 ms". So I guess you need to use an array to get each line if you're plan is to return the data, but this command should work for you. Like I said before just give us some more information: code, program, examples of what you've done etc... Link to comment https://forums.phpfreaks.com/topic/42233-solved-start-a-program-via-php-page/#findComment-205017 Share on other sites More sharing options...
peeps Posted March 12, 2007 Author Share Posted March 12, 2007 I guess what I am trying to do is remotly start a server on my machine. What I want to happen is for the command prompt to open on the server computer so I can then connect to it. The bat file dedserver calls paintball2.exe with the listed arguments. I have tried the following and they seem to "run the program" but only give me the output back. exec("C:\wamp\www\paint\dedserver.bat"); system("C:\wamp\www\paint\dedserver.bat"); exec("C:\wamp\www\paint\paintball2.exe +set dedicated 1 +set public 1 +exec server.cfg +map airtime3"); system("C:\wamp\www\paint\paintball2.exe +set dedicated 1 +set public 1 +exec server.cfg +map airtime3"); Link to comment https://forums.phpfreaks.com/topic/42233-solved-start-a-program-via-php-page/#findComment-205810 Share on other sites More sharing options...
trq Posted March 12, 2007 Share Posted March 12, 2007 The command prompt will not open when executed from within a script. Any programs executed by php will run silently, in the background. Link to comment https://forums.phpfreaks.com/topic/42233-solved-start-a-program-via-php-page/#findComment-205813 Share on other sites More sharing options...
peeps Posted March 12, 2007 Author Share Posted March 12, 2007 So there is no way to do what I am trying to do is there? That is dissapointing. Thanks for the help. Link to comment https://forums.phpfreaks.com/topic/42233-solved-start-a-program-via-php-page/#findComment-205823 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.