我的代碼如下淨SSH預計打印輸出
use Net::SSH::Expect;
my $ssh = Net::SSH::Expect->new (
host => "$node_name",
user => 'admin',
timeout => 10,
raw_pty => 1,
);
$ssh->run_ssh() or die "SSH process couldn't start: $!";
$ssh->waitfor('password: ');
$ssh->send("$password");
$ssh->waitfor('mml> ');
@ls=$ssh->exec("$command");
print @ls;
#BREAK1: At this point remote device ask for "Press Enter to continue..." because output is more than one page..that is why below code
while ($ssh->waitfor('continue')) {
$line=$ssh->send("\n");
print $line;
}
我想打印所有的輸出拍攝的,但它只能打印這是由@ls=$ssh->exec("$command");
捕獲,它不打印這是由下面的代碼BREAK1
捕獲任何東西。當輸出大模塊的
您好,我試過相同,它可以很好地用於第二頁只(基本上我有5-6頁輸出的)..它打印兩頁,但沒有打印第二頁以後的頁面....任何幫助? – Mahesh
我認爲你可以嘗試檢查每一行'繼續',如果發現模式發送返回飼料在while循環內。另一種方法是在調用waitfor('continue')循環後使用before()函數。 –
天啊!最後它完成了......做{sr-> send(「\ n」); $ line = $ ssh-> read_line(); push(@ls,「$ line」); } while($ line!〜/ mml> /); foreach(@ls){ print「$ _ \ n」; } – Mahesh