Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Old 02-04-2005, 07:47 PM   #1 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,444
sde is on a distinguished road
Executing a server script from PHP

this question was emailed to me, so i thought i'd answer it in the php forum where it should be:
Quote:
hi its about web panel, i write similar panel on php and i need know mby you know how you starting hlds server through httpd?

i try any funcions system (); exec (); etc...
but that funcions didnt work....
in my config of php have acess on that funcions.

i try write system ("/etc/init.d/hlds start"); but it didnt work because no have root acess

mby you know how through httpd starting my hlds ?
I would make a script that starts the half-life server and store it in a subdirectory of my user account.

/user/sde/scripts/start-hlds.sh
Code:
#!/bin/sh
./hlds_run -game cstrike +noipx +ip 1.2.3.4 +port
 27015 +map de_dust2 +maxplayers 21 +localinfo
now if i want PHP to be able to modify this script, i need to change the permissions so everyone can execute it.
Code:
chmod 755 /user/sde/scripts/start-hlds.sh
now the script is setup and has permissions so anyone can read or execute it. let's use the php exec() function to now execute this script:
PHP Code:
<?
exec
("/user/sde/scripts/start-hlds.sh");
?>
let me know how it goes.
__________________
Mike
sde is offline   Reply With Quote
Old 02-04-2005, 08:13 PM   #2 (permalink)
Tmsoft
Registered User
 
Join Date: Feb 2005
Posts: 2
Tmsoft is on a distinguished road
Quote:
Originally Posted by sde
this question was emailed to me, so i thought i'd answer it in the php forum where it should be:


I would make a script that starts the half-life server and store it in a subdirectory of my user account.

/user/sde/scripts/start-hlds.sh
Code:
#!/bin/sh
./hlds_run -game cstrike +noipx +ip 1.2.3.4 +port
 27015 +map de_dust2 +maxplayers 21 +localinfo
now if i want PHP to be able to modify this script, i need to change the permissions so everyone can execute it.
Code:
chmod 755 /user/sde/scripts/start-hlds.sh
now the script is setup and has permissions so anyone can read or execute it. let's use the php exec() function to now execute this script:
PHP Code:
<?
exec
("/user/sde/scripts/start-hlds.sh");
?>
let me know how it goes.

Yep but i have different system

halfd - where is all configs -game cstrike +noipx +ip 1.2.3.4 +port
in server.cfg all configs what i need.

I dont want changing system i want start from php
/etc/init.d/halds start .

Mby have some another ideas ?
Tmsoft is offline   Reply With Quote
Old 02-04-2005, 08:48 PM   #3 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,444
sde is on a distinguished road
just make a script with exactly the code you use to start the server from the command line. ( change the sh script to your own code )

then use php to execute that script.
__________________
Mike
sde is offline   Reply With Quote
Old 02-05-2005, 08:39 AM   #4 (permalink)
idx
Senior Grasshopper
 
idx's Avatar
 
Join Date: Jun 2003
Location: FL
Posts: 317
idx is on a distinguished road
If the apache user (www?) can't execute /etc/init.d/halds, then you either:

1 - Make sure that user can execute scripts in that directory.. This isn't exactly a great idea due to security concerns.


2 - As sde mentioned, make a copy of the start up script so the apache user can execute it.

..even then it might not work depending on what unix user needs to be running the hlds daemon. (eg: root or hlds?) If it needs to be root or suid to another user, then it might be a bit harder.

3. Maybe setup a page that (is authenticated) and writes a request to a certain directory. Then have a cron that checks for this file and starts hlds if this file exists...

-r
idx is offline   Reply With Quote
Old 02-05-2005, 11:12 AM   #5 (permalink)
Tmsoft
Registered User
 
Join Date: Feb 2005
Posts: 2
Tmsoft is on a distinguished road
heh idea about cron i think better, try that way
tnx for any help
Tmsoft is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

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
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP ban IP range script Boks PHP 23 05-21-2008 03:07 AM
php script that can upload binary data infinite_root PHP 9 08-27-2004 06:03 PM
Specifying SMTP server for PHP mail() Epsilon PHP 2 03-18-2004 12:20 AM
sending POST multiple post requests in one php script. sde PHP 2 08-09-2003 05:10 PM


All times are GMT -8. The time now is 12:03 AM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting