[PHP] How to start / stop Linux Server -
d123 - 10.05.2009
Hi.
Im tryin 2 make a Control Panel for SAMP with PHP. I use Linux.
I got this functions:
Код:
function StopServer(){
echo shell_exec('pkill -f samp02Xsvr');
echo "<br />";
}
function StartServer(){
echo shell_exec('/opt/samp/start.sh &');
echo "<br />";
}
But it just doesnt work. No error. Nothin.
I'm usin lampp with php5. Do i need to change something in the configuration of lampp or php? If yes, what?
or is my code just wrong?
P.s. Startin' server manual with start.sh works.
Re: [PHP] How to start / stop Linux Server -
KingJ - 10.05.2009
Take off the echo, echo means that it will output that rather than executing it.
Re: [PHP] How to start / stop Linux Server -
d123 - 10.05.2009
Sounds strange, cause shell_exec gives back the output from that function. And the function gives back output also without echo. i'll try also if i know that it can't be because of that
Re: [PHP] How to start / stop Linux Server -
KingJ - 10.05.2009
The function itself may also echo stuff back (such as the passed command) but you must remove the echo.
In addition, you must call the StartServer / StopServer function for it to actually execute that code.
Re: [PHP] How to start / stop Linux Server -
d123 - 10.05.2009
Lol I know, im not stupid.
I just wrote the functions. of course i call em. Thats not the whole Script
http://php.net/shell_exec
the function doesnt echo sth itsel. it returns the output.
Re: [PHP] How to start / stop Linux Server -
Woet - 11.05.2009
Quote:
Originally Posted by d123
Hi.
Im tryin 2 make a Control Panel for SAMP with PHP. I use Linux.
I got this functions:
Код:
function StopServer(){
echo shell_exec('pkill -f samp02Xsvr');
echo "<br />";
}
function StartServer(){
echo shell_exec('/opt/samp/start.sh &');
echo "<br />";
}
But it just doesnt work. No error. Nothin.
I'm usin lampp with php5. Do i need to change something in the configuration of lampp or php? If yes, what?
or is my code just wrong?
P.s. Startin' server manual with start.sh works.
|
Do not ever run the servers under apache, this means it's insecure, especially when doing shared hosting (multiple users on 1 server).
Always run every server under it's own shell.
Quote:
Originally Posted by KingJ
Take off the echo, echo means that it will output that rather than executing it.
|
No, echo will of course execute it too, what else does it have to output?
Re: [PHP] How to start / stop Linux Server -
d123 - 11.05.2009
I'm the only one who uses the Apache.
On the Server just is 1 Samp Server, 1 CSS Server and Apache.
And the Apache was just installed for the control panel for SAMP.
Hm But how to fix the problem, that it doesn't work?