Click to See Complete Forum and Search --> : Need Help
fatdaddy
04-26-2003, 12:50 PM
I am looking for a php page capable of issuing commands on my server. (Red Hat 7.3) I need for this page to be secure and require specific login info.
The reason I need this is to allow clients to remotely start and stop their counter-strike servers from the web. Unfortunately my understanding of php and linux are inadequate for this.
If anyone can help me code this, or point me to a place where this type of page/script exists I would be eternally gratefull. I have spent the last month becoming good friends with google.
Also I am at a loss for the correct command to stop a process which is running in the background (&). Is there a way to assign a specific id to a process each time it starts?
Thanks in advance.
bwkaz
04-26-2003, 02:28 PM
Every time any process starts, it gets a process ID (pid). These IDs are unique on a system -- no two processes will ever have the same PID if they're running at the same time.
ps ax will tell you the command line that was used to start every process that's running on your machine, and the PID is the leftmost column. So you can kill 1233, assuming the leftmost column contains "1233" for the process you launched in the background.
Also, if you're still running the same shell that launched the background process, you can look at what job number the shell gave that process (it gets printed when the background process lanunches), and then kill %thatjobnumber. Most of the time, that job number will be 1, so you'd kill %1
As for the PHP question, I don't really know.
gotenks2
04-26-2003, 02:37 PM
Originally posted by fatdaddy
I am looking for a php page capable of issuing commands on my server. (Red Hat 7.3) I need for this page to be secure and require specific login info.
The reason I need this is to allow clients to remotely start and stop their counter-strike servers from the web. Unfortunately my understanding of php and linux are inadequate for this.
Howdy,
You may want to look into "webmin". It comes as a default install option in mandrake 9.0/9.1. I haven't looked into whether or not you will have any problems setting it up on redhat 7.3 but I don't really forsee any problems. Basically it allows you to set up logins over a secure http session. It looks as though it's set up so you can add/remove modules for particular services. It probably wouldn't be very difficult to set it up and configure logins for your users with a CS module for starting/stopping the servers.
gotenks2
fatdaddy
04-26-2003, 04:06 PM
Thank you for the quick replies.
I loaded webmin but have been unable to create users with limited access. I am afraid of security holes which may exist within the program. I will continue to research using the usermin module.
I don't want to give clients ssh access. I remember my first experience with it. Having been in a windows environment for so long it was a bit intimidating and confusing at first. I want to simplify that process by just offering two options.. start or stop.
I may be misunderstanding your response about process numbers. What I would like to do, which may not be possible, is when a process begins assign it the same PID always. So that the kill script is simplified.
If there is another way instead of using php, like cgi, I am willing to learn or try anything.
Thanks Again.
SPo0n
04-26-2003, 07:29 PM
php's exec function may help. Try www.php.net/exec
If you need further help pop into #php.uk on quakenet and me or someone else will help
bwkaz
04-26-2003, 07:51 PM
Originally posted by fatdaddy
What I would like to do, which may not be possible, is when a process begins assign it the same PID always. No, not possible. The kernel assigns PIDs, not userspace.
However, depending on how PHP's exec thing works, you can probably figure out what the PID is, after exec'ing it.
chrism01
04-27-2003, 08:40 AM
You could try this old trick: make the controlling script save the pid in a known file in a known location eg
/home/username/prog.pid
Then, the stop script just reads the file and extracts the pid.