[PHP] Sending shell commands from PHP
Hey guys, I am building a webinterface to set up a Quake 3 Arena server on my Linux server. I have the variables $map, $timelimit, $fraglimit etc..
I want the PHP file to send out a command like: . /q3ded +set dedicated 1 +exec ffa.cfg +map q3dm17 +set pure 0 & I tried exec() and shell_exec() but I can't get it to work? :( Does somebody have an idea? |
Maybe give the full path for q3ded, also on a side note,
the + sign before the options is not POSIX compliant... Try the inversed quotes : PHP Code:
|
I tried:
$pid = "/usr/local/games/quake3/./q3ded +set dedicated 1 +exec ffa.cfg +map q3dm17 +set pure 0 &"; shell_exec($pid) or die(); and $pid = `/usr/local/games/quake3/./q3ded +set dedicated 1 +exec ffa.cfg +map q3dm17 +set pure 0 &`; shell_exec($pid) or die(); and I tried replacing shell_exec with exec, but it keeps on giving no output, and not starting the server :( Edit: or maybe it is because the webserver is logged in as apache and has no rights to start it? If so, how do I give those rights to apache? |
Try to set the path for ffa.cfg and q3dm17 files as well
Do no use the shell_exec() with the inversed quote as the inversed quotes mean execute whatever is between them Maybe before do a test with PHP, you should try to test the command (with full path for all files) in a console to see |
If I run this command:
/usr/local/games/quake3/./q3ded +set dedicated 1 +exec ffa.cfg +map q3dm17 +set pure 0 & through 'Command Shell' in Webmin, I get an output (it still doesn't start, but that's problem #2 now). When I try it with my code: $command = "/usr/local/games/quake3/./q3ded +set dedicated 1 +exec ffa.cfg +map q3dm17 +set pure 0 &"; $output = shell_exec($command); echo($output); I don't get any output? What's up with that? Edit: when I put in 'uptime' as $command, it does give me the correct output... |
All times are GMT -5. The time now is 06:59 AM. |