如果使用PHP-SSH2在远程SSH服务器中存在目录“xyz”,如何重新启动?
<?php
function fsmoke_ping($command_name1, $menu_name1, $title_name1, $host_ip1)
{
$connection = ssh2_connect('http://xxxx.com', 22);
ssh2_auth_password($connection, 'username', 'password');
$sftp = ssh2_sftp($connection);
$handle = file_exists('ssh2.sftp://' . $sftp . '/etc/xyz/devices/$menu_name1', 'w+') or die('Cannot open file: '.$menu_name1);
$data = "++$menu_name1\nprobe = $command_name1\n menu = $menu_name1\n title = $title_name1\n host = $host_ip1";
fwrite($handle, $data);
fclose($handle);
exec(`sudo /etc/init.d/xyz reload`);
}
?>
在这个
exec(`sudo /etc/init.d/xyz reload`);
无法正常工作,所以我如何在这里重新启动?
最佳答案
显然是ssh2_exec。 exec
将在本地计算机上执行语句。
关于php - 使用PHP SSH2重新启动远程应用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16104152/