LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Call a shell script from php? (https://www.linuxquestions.org/questions/programming-9/call-a-shell-script-from-php-290267/)

jharper101 02-14-2005 06:07 PM

Call a shell script from php?
 
I have a shell script named "start" that starts a gameserver for me:

#!/bin/sh

start=`date '+%H:%M on %d/%m/%y'`
echo "CoD UO Match server started @ $start" >>/usr/servers/coduomatch1/CoDUOMatch1.log
screen -A -m -d -S CoDUOMatch1 ./coduo_lnxded +set net_port 28965 +exec coduo_sd.cfg +set sv_cheats 0 +map_rotate +set fs_homepath /usr/servers/coduomatch1 +set fs_basepath /usr/servers/coduomatch1 >/dev/null 2>&1 &
echo $! >CoDUOMatch1.pid

I would like to make a simple web page with a button on it to call this script. I can't seem to find any info on how to do this using my usual search methods. Can someone point me in the right direction?

keefaz 02-14-2005 06:14 PM

I don't know if php will success with screen program, anyway try :

make a form with action="script.php"

And for script.php :
PHP Code:

<?php
system
("/path/to/start");
?>

Maybe edit your start script to give the full path to screen program in case

nixcraft 02-15-2005 12:51 AM

Use passthru() function it replaces both exec() and system(). It will execute shell script (or other program( and display raw output to your interface. Better read http://in2.php.net/manual/en/function.passthru.php


All times are GMT -5. The time now is 04:32 AM.