Jump to content

Recommended Posts

The Story/Setup:

I have an Ubuntu FF Server up and running.  However it is very noisy and it sits in my bedroom with the printer and all my other networking stuff.

 

However, if I am not at home... I would like a way for my wife to be able to shut the box off without having to SSH into the box, but instead click a simple link to turn it off.  However, nothing has worked so far.

 

Anyone have any ideas?

 

What I have so far:

        $v = "";

        if($_GET['command']=='shutdown')
        {
                echo("<h1>SHUTTING DOWN SERVER</h1>");
                $loadpage=false; // for something else, ignore this
                $v .= shell_exec('sync');
                $v .= shell_exec('sync');
                $v .= shell_exec('shutdown');
                echo("".$v."");
        }

// much later down the road

 

<li><a href="index.php?command=shutdown">Shutdown the
Server</a>

 

When I run this... it displays the "<h1>SHUTTING DOWN SERVER</h1>" but does not shut down the server.

 <?php

function kill($_GET['command']=='shutdown'){
       if(shall_exec::is_running($_GET['command']=='shutdown')){
           shell_exec("kill -KILL ,$_GET['command']=='shutdown'");
           return true;
       }else return false; ?>

First u must be sure u are executing commands, as having safe_mode on will stop functions like shell_exec(), exec(), system(), passthru() and ` (backtick operator).

 

Im far from a linux profficient, but not sure apache will have the privileges to run a shutdown command. U can grant those permissions, but again ull face the problem that anyone can shutdown (or whatever) your web server from a simple script. Hope it helped.

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.