开发者

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

开发者 https://www.devze.com 2022-12-29 20:40 出处:网络
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.

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 th开发者_如何学编程at 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.


Have checked this one http://www.linuxquestions.org/questions/linux-newbie-8/shutdown-and-reboot-linux-system-via-php-script-713379/ ?

0

精彩评论

暂无评论...
验证码 换一张
取 消