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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
05-28-2004, 04:52 AM
|
#1
|
LQ Newbie
Registered: May 2004
Posts: 4
Rep:
|
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!
|
|
|
05-28-2004, 05:20 AM
|
#2
|
Member
Registered: Mar 2004
Location: Brisbane, Australia
Distribution: FreeBSD, Suse
Posts: 103
Rep:
|
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.
|
|
|
05-28-2004, 05:29 AM
|
#3
|
LQ Newbie
Registered: May 2004
Posts: 4
Original Poster
Rep:
|
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?
|
|
|
05-28-2004, 06:37 AM
|
#5
|
LQ Newbie
Registered: May 2004
Posts: 4
Original Poster
Rep:
|
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?
|
|
|
05-28-2004, 06:53 AM
|
#6
|
Member
Registered: Mar 2004
Location: Brisbane, Australia
Distribution: FreeBSD, Suse
Posts: 103
Rep:
|
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.
|
|
|
05-28-2004, 06:54 AM
|
#7
|
Member
Registered: Mar 2004
Location: Brisbane, Australia
Distribution: FreeBSD, Suse
Posts: 103
Rep:
|
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
|
|
|
05-28-2004, 06:58 AM
|
#8
|
LQ Newbie
Registered: May 2004
Posts: 4
Original Poster
Rep:
|
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?
|
|
|
05-28-2004, 07:24 AM
|
#9
|
Member
Registered: Mar 2004
Location: Brisbane, Australia
Distribution: FreeBSD, Suse
Posts: 103
Rep:
|
just tried it...know what you mean!
stumped, but if you work it out i really would like to know
|
|
|
05-28-2004, 07:31 AM
|
#10
|
Member
Registered: Mar 2004
Location: Brisbane, Australia
Distribution: FreeBSD, Suse
Posts: 103
Rep:
|
|
|
|
05-28-2004, 06:39 PM
|
#11
|
LQ Newbie
Registered: Jul 2003
Location: MA, USA
Distribution: Mandrake,Debian,Zaurus
Posts: 17
Rep:
|
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
|
|
|
All times are GMT -5. The time now is 06:10 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|