Jump to content

[SOLVED] system command


AV1611

Recommended Posts

You won't need to kill it as root, root didn't start the process. Something like....

 

<?php

  exec('kill -9 $(ps -C server-bin | grep server-bin | awk "{print $1}")');

?>

 

should go pretty close providing theres only one instance running.

Link to comment
Share on other sites

That worked just as expected.

 

I've got 2 final minor problems.

 

1.

 

When I issue the exec() to start the server, it starts perfectly but the browser never gets any info so it sits with an hourglass and never times out or whatever.  You can close the browser ok, but that's kinda annoying.  Suggestions?  I put an echo success at the end of the clause but it never get's to it.  Suggestions?

 

2.

 

The stop worked flawlessly.  I need to modify that to some kind of check to see if the server is already started before trying to start it... I can handle the clauses, I just could use some help with the $var made from the exec() to see if it is running already.  Hope that makes sense.

 

 

Link to comment
Share on other sites

BTW

<?php

if(!isset($_GET['run']))

{

    echo'

    <a href="server3.php?run=start">Start Game Server</a><br />

    <a href="server3.php?run=stop">Stop Game Server</a><br />

    ';

    die('You must specify an option');

}

if($_GET['run']=="start")

    {

    set_time_limit(3); //<--- did not help

    chdir('/home/aops-lnxded-2.8.1/System');

    exec('/home/aops-lnxded-2.8.1/System/server-bin GLOBAL sniper_range.aao -nohomedir ini=server.ini &');

    echo 'Server Started...'; //<--- never get here

    }

elseif($_GET['run']=="stop")

    {

    exec('kill -9 $(ps -C server-bin | grep server-bin | awk "{print $1}")');

    }

?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.