start server in php
#1

<?php
exec('cd \samp');
exec('start samp-server.exe');
echo "Server started!";
?>


nothing happens just loading forever

help will be appreciated

im running xampp apache on win
Reply
#2

i am trying same but fail! but if u get solloution then plz post link on my page Kiss u!
Reply
#3

Try this command:

cmd /C start /D /server/dir/here /B samp-server.exe

I'm not sure about it but it should work.
Reply
#4

^^ like how would i use that with php exactly?
Reply
#5

Quote:
Originally Posted by jamesbond007
Посмотреть сообщение
<?php
exec('cd \samp');
exec('start samp-server.exe');
echo "Server started!";
?>


nothing happens just loading forever

help will be appreciated

im running xampp apache on win
Is shell() and exec() active in php.ini?
I believe XAMPP/WAMP disables some features (security)
Reply
#6

ok i figure out now i can run commands in exec on my comp .. but now when i run i get samp-server.exe not found any one knows why?

hhere is my code
Код:
<?php
  exec("cd C:\\xampp\\htdocs\\samp");
  exec("start samp-server.exe");
  echo "Server started!";
?>
Reply
#7

bumbu,mmbumbumbumbumbumbummp anyone ??
Reply
#8

Because when you cd, it only changes directory for that call. Your second call for exec() doesn't recognize your use of 'cd' because it goes back to default.

Basically:
PHP код:
exec("cd /directory"); 
// cd is only remembered for the command above. It's forgotten the next time you call exec()
exec("start samp-server.exe"); // It can't find it because it doesn't remember the cd command used 
Try merging the two commands in to one call for exec().
Reply
#9

You should take a look into antctrl by Westie.
Reply
#10

Quote:
Originally Posted by Cyanide
Посмотреть сообщение
You should take a look into antctrl by Westie.
This user speaks words of goodness.

First of all, you have to start the server relative to the directory. Thus, an approach similar to IronBoy is the only way:

Код:
cmd /C start /D "\server\dir\here" /B "samp-server.exe"
Also, you'll have to start the server with a COM object.

Why, you're asking me. Well, the SA-MP process doesn't daemonise - it freezes the webpage by in effect blocking the socket, so you'll have to trick it into doing so manually. I'll give you an example from my code - well, a simplified version of it:

PHP код:
$pCOM = new COM("WScript.Shell");
$pCOM->Run('cmd /C start /D "'.addslashes(COM_RELDIR).'" /B '.COM_EXEC0false); 
Pretty much the only reliable way to do things.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)