我的代码如下净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