jianwei87 Posted March 4, 2008 Share Posted March 4, 2008 i have upload my script file to my web hosting. and now i need to run my script. in side the script the have include exe, *.sh file. may i know how to going to write the php code to let my script running on my web hosting. below this are my exe and *.sh file name : char-server.sh char-server.exe map-server.sh map-server.exe map-server.sh map-server.exe how to write the code and let my script run. thank you Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted March 4, 2008 Share Posted March 4, 2008 To execute a command/program installed on the server via a PHP script you'll need to look into the following exec functions. Quote Link to comment Share on other sites More sharing options...
jianwei87 Posted March 4, 2008 Author Share Posted March 4, 2008 To execute a command/program installed on the server via a PHP script you'll need to look into the following exec functions. actually i'm know nothing on php. and can u help me to write the php code. pls pls Quote Link to comment Share on other sites More sharing options...
jianwei87 Posted March 4, 2008 Author Share Posted March 4, 2008 now i get the code and can let me know which part i should change or help me to change . <?php $script_start = './script.sh start'; $script_stop = './script.sh stop'; switch(strtolower(trim($_GET['cmd']))){ case 'start': $cnsl = shell_exec($script_start); echo('Trying to start the server...<br />'); if(!empty($cnsl)) echo($cnsl.'<br />'); echo('< <a href="./'.basename($_SERVER['SCRIPT_FILENAME']).'">Back</a>'); break; case 'stop': $cnsl = shell_exec($script_stop); echo('Trying to stop the server...<br />'); if(!empty($cnsl)) echo($cnsl.'<br />'); echo('< <a href="./'.basename($_SERVER['SCRIPT_FILENAME']).'">Back</a>'); break; default: echo('> <a href="./'.basename($_SERVER['SCRIPT_FILENAME']).'?cmd=start">Start</a><br />'); echo('> <a href="./'.basename($_SERVER['SCRIPT_FILENAME']).'?cmd=stop">Stop</a>'); break; } ?> Quote Link to comment Share on other sites More sharing options...
jianwei87 Posted March 5, 2008 Author Share Posted March 5, 2008 how to write the code to let my script running on webspcae. pls help me :'( :'( :'( Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted March 5, 2008 Share Posted March 5, 2008 Not all hosts will allow to run system commands via the various exec functions what is the purpose of script.sh Quote Link to comment 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.