Jump to content

[SOLVED] Start a Program via php page


peeps

Recommended Posts

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

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!

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

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");

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.