LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 02-14-2005, 06:07 PM   #1
jharper101
LQ Newbie
 
Registered: Feb 2005
Posts: 3

Rep: Reputation: 0
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?
 
Old 02-14-2005, 06:14 PM   #2
keefaz
LQ Guru
 
Registered: Mar 2004
Distribution: Slackware
Posts: 6,797

Rep: Reputation: 943Reputation: 943Reputation: 943Reputation: 943Reputation: 943Reputation: 943Reputation: 943Reputation: 943
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
 
Old 02-15-2005, 12:51 AM   #3
nixcraft
Member
 
Registered: Nov 2004
Location: BIOS
Distribution: RHEL3.0, FreeBSD 5.x, Debian 3.x, Soaris x86 v10
Posts: 379

Rep: Reputation: 30
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
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Shell Script call API treotan Programming 1 08-22-2005 10:59 PM
call a c program in a shell script jagman Programming 4 04-05-2005 04:58 PM
call perl cgi script from php j-ray Programming 2 01-14-2005 08:23 AM
My shell script can't seem to call another script kakho Programming 3 04-17-2004 09:21 AM
Urgent: Call a C program through Linux shell script nuwandee Programming 14 04-10-2004 07:31 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 04:23 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration