0
我試着發送一個執行命令在PHP到遠程服務器(aerohive)。但執行命令什麼都不做。ssh2_exec在PHP不工作
我有我的ssh2擴展安裝和身份驗證也正常工作。
下面是代碼:
if (!function_exists("ssh2_connect"))
die("function ssh2_connect doesn't exist");
if (!($con = ssh2_connect("myipadresherenotshowingtoyouguys", 22))) {
echo "fail: unable to establish connection\n";
} else {
// try to authenticate with username root, password secretpassword
if (!ssh2_auth_password($con, "blablabla", "blablabla!")) {
echo "fail: unable to authenticate\n";
} else {
// allright, we're in!
echo "okay: logged in...\n";
// execute a command
$command = 'ssid "Wentzo test2" hide-ssid';
if (!($stream = ssh2_exec($con, $command))) {
echo "fail: unable to execute command\n";
} else {
$stream2 = ssh2_exec($con, $command_save);
// collect returning data from command
stream_set_blocking($stream, true);
$data = "";
while ($buf = fread($stream, 4096)) {
$data .= $buf;
}
fclose($stream);
}
}
}
您可以打開錯誤報告,並告訴我們錯誤消息的php.ini文件? – 2014-12-02 10:10:25
沒有錯誤! :( – 2014-12-02 10:33:29