2017-09-14 38 views
1

你好,我是運行多個SSH命令在一個會議上,兩個命令執行,並在命令提示符下顯示結果(第一結果顯示再經過一分鐘的第二個結果是顯示),但在我的網頁只顯示了一半的結果,這是第一次執行的結果,只是第二次執行的一小部分。所以請有人可以幫我嗎? 這裏是我的代碼:網頁僅顯示了SSH執行的部分結果

echo $ssh->read('[email protected]:~$'); 
$ssh->write("dis inter eth-trunk 3\n"); // note the "\n" 
$results= $ssh->read('[email protected]:~$'); 

echo $results; 
$myfile = fopen("data1.txt", "w") or die("Unable to open file!"); 
$txt = $results; 
fwrite($myfile, $txt); 
fclose($myfile); 

echo $ssh->read('[email protected]:~$'); 
$ssh->write("dis inter eth-trunk 12\n"); // note the "\n" 

$result= $ssh->read('username:~$'); 
echo $result; 

回答

0

我注意到你的提示是每個$ssh->read()電話不同。

我想知道,如果您的第二次嘗試是在發送完整輸出之前超時,此時$ssh->setTimeout(30)可能工作。