Home > Backend Development > PHP Tutorial > PHP重新启动远程机器

PHP重新启动远程机器

WBOY
Release: 2016-06-13 12:08:34
Original
1384 people have browsed it

PHP重启远程机器
1.在本地CMD环境下能够正常执行代码shutdown -r -m \\192.168.1.113 -t 0 -f
2.在PHP环境下能够执行代码 exec("mkdir c:\\test",$out);
print_r($out);
?>
3.我想重启远程机器所以写了如下代码exec("shutdown -r -m \\\\192.168.1.113",$out);
print_r($out);
?>但是却运行不成功 ,远程机器 无法重启,求助各位大神
------解决思路----------------------
server A 重啟 server B
server A domain http://servera.com/shutdown.php
server B domain http://serverb.com/shutdown.php apache 需要是管理員權限

在server A的shutdown.php中,使用curl訪問server B的shutdown.php就可以實現了。

server A
shutdown.php

<br /><?php<br />$ch = curl_init();<br />curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);	<br />curl_setopt($ch, CURLOPT_URL, 'http://serverb.com/shutdown.php');<br />$response = curl_exec($ch);<br />if($error=curl_error($ch)){<br />  die($error);<br />}<br />curl_close($ch);<br />echo 'shutdown server b success';<br />?><br />
Copy after login


server B
shutdown.php
<br /><?php<br />$cmd = "shutdown -r";<br />exec($cmd, $out);<br />echo $out;<br />?><br />
Copy after login

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template