LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 05-28-2004, 04:52 AM   #1
cartoonwally
LQ Newbie
 
Registered: May 2004
Posts: 4

Rep: Reputation: 0
Execute Script from Website


Hey guys,
The Dreaded Question :

I have a gaming server and i want to develop a start/stop/restart script for it. Now, the start, stop and restart can all be different scripts it doesn't matter. But, i need to be able to run them from a website.

a) What type of script should it be
b) what type of website scripting?
c) Where does the script need to be on the server?

Thanks guys!
 
Old 05-28-2004, 05:20 AM   #2
kinasz
Member
 
Registered: Mar 2004
Location: Brisbane, Australia
Distribution: FreeBSD, Suse
Posts: 103

Rep: Reputation: 15
I would probably do the site script with php, because I know you can execute programs with it.

You can do the script to start the server with bash ie:

#start -check out /etc/rc.d/rc.3/somefile for an example of how this works
case $1 in
start)
start stuff here
;;
stop)
kill it here
;;
restart)
stop
start
;;
esac

#EOF

then chmod it to make executable: ie chmod 777

As far as I know this script will need to be on the same machine as the server in order to call it with php. You can put it anywhere the server can access as long as it as permissions to execute the file and you reference it with its absolute filename. I am not sure about any security issues involved with this though. I'm sure there is other ways but this way seems easy.

Edit: to execute you script with php, you can use exec()

Last edited by kinasz; 05-28-2004 at 05:24 AM.
 
Old 05-28-2004, 05:29 AM   #3
cartoonwally
LQ Newbie
 
Registered: May 2004
Posts: 4

Original Poster
Rep: Reputation: 0
Ok, im a little bit of a n00b. Explain how to execute it using exec(). I have figured that i may use the script by using authentication on the http protocol. This means that the script will link up to the game on the server and i can remotely start/stop it wherever i like. =)

So can you give me an example of the exec() string?
 
Old 05-28-2004, 05:48 AM   #4
kinasz
Member
 
Registered: Mar 2004
Location: Brisbane, Australia
Distribution: FreeBSD, Suse
Posts: 103

Rep: Reputation: 15
http://www.google.com.au/search?q=ph...e+Search&meta=

first or second result, I haven't really used exec much myself...read into it.
 
Old 05-28-2004, 06:37 AM   #5
cartoonwally
LQ Newbie
 
Registered: May 2004
Posts: 4

Original Poster
Rep: Reputation: 0
Ok, thats working great.
Now, i am sure its possible but how do i get my php script to execute the shell which is on another server. Note: i can put the script online (http) if it makes it any easier?
 
Old 05-28-2004, 06:53 AM   #6
kinasz
Member
 
Registered: Mar 2004
Location: Brisbane, Australia
Distribution: FreeBSD, Suse
Posts: 103

Rep: Reputation: 15
a couple of ways maybe...

1. write a client/server app with c. client listens on port x for start server sentinal, then starts with execl(). Server side gets executed by php app, which then opens socket to client and sends sentinal

2. run apache on the other server(s2) on a non standard port.
When you want to start the script on s2: server1 opens the page on s2 with whatever authentication string/variables you want in the url. When page gets opened on s2, php executes the script.

use a different variable in the url to signal stop, etc


I am sure there is an easier way but this is the only way I know how to do it. Hope it helps.
 
Old 05-28-2004, 06:54 AM   #7
kinasz
Member
 
Registered: Mar 2004
Location: Brisbane, Australia
Distribution: FreeBSD, Suse
Posts: 103

Rep: Reputation: 15
it just occured to me that you could use a script to ssh into the other server, execute the remote script, logoff.

just a thought
 
Old 05-28-2004, 06:58 AM   #8
cartoonwally
LQ Newbie
 
Registered: May 2004
Posts: 4

Original Poster
Rep: Reputation: 0
Im actually working on that now =P haha...
only problem is, i can't specify a password in the ssh command line and the thing keeps asking me if i want to continue, which, when i don't have control over input will screw it up. Any solutions?
 
Old 05-28-2004, 07:24 AM   #9
kinasz
Member
 
Registered: Mar 2004
Location: Brisbane, Australia
Distribution: FreeBSD, Suse
Posts: 103

Rep: Reputation: 15
just tried it...know what you mean!

stumped, but if you work it out i really would like to know
 
Old 05-28-2004, 07:31 AM   #10
kinasz
Member
 
Registered: Mar 2004
Location: Brisbane, Australia
Distribution: FreeBSD, Suse
Posts: 103

Rep: Reputation: 15
the solution -- http://www.cpqlinux.com/expect.html
 
Old 05-28-2004, 06:39 PM   #11
phlogistonjohn
LQ Newbie
 
Registered: Jul 2003
Location: MA, USA
Distribution: Mandrake,Debian,Zaurus
Posts: 17

Rep: Reputation: 0
You can make ssh work without using a password by using public/private keys. You generate these with ssh-keygen, and then append the contents of ~/.ssh/id_rsa.pub to ~/.ssh/authorized_keys2 on the other machine.

A more thourough explanation: http://www.modwest.com/help/kb20-90.html
 
  


Reply



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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
execute a script upon logon Starch Linux - Newbie 3 05-12-2005 04:04 PM
Cannot execute a script grueugene Programming 15 01-27-2005 04:50 AM
shell script won't execute brandnewbie Linux - Newbie 7 08-10-2004 01:30 PM
How to execute script after login? gmitra Linux - General 2 02-19-2003 11:39 AM
Execute a script from iptables padukes Linux - Networking 6 03-17-2002 06:15 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 08:47 AM.

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