Creating a PHP web page that enables you to reboot the server in Linux?

Posted by Stuart on Stack Overflow See other posts from Stack Overflow or by Stuart
Published on 2010-05-08T14:53:56Z Indexed on 2010/05/08 14:58 UTC
Read the original article Hit count: 145

Filed under:
|
|

I want to create a web page that allows the user to initiate a reboot on the linux server. Obviously this would only be avaliable for system admins and would also be controlled by using iptables.

Below is a sample of code that I was thinking of using but I wanted to know if there is another way to do this and how also to use this in a web page? Also is there any thing else that I should consider?

$command = "cat $pass | su -c 'shutdown -r now'";
$output = array();
try{
    echo shell_exec($command);
    exec($command, $output);
    system($command, $output);
}
catch(Exception $e) {
    print "Unable to shutdown system...\n";
}

foreach ($output as $line) {
    print "$line<br>";
}

Thanks in advance.

© Stack Overflow or respective owner

Related posts about php

Related posts about linux