我正在使用
Net::SSH::Expect
$ssh->exec("no paging");
$ssh->send("sh startup-config");
$ssh->peek(0);
my $line;
while( defined ($line = $ssh->read_line()) ) {
# get configuration content
if ( $line !~ /show running-config|Building Configuration...|Current configuration|^\s*$/ ) {
push @config, $line;
}
}
if ( @config <= 0 ) {
$msg = "No data retrieved, the capture timeout may be too low.";
$ssh->close();
return(244, $msg);
}
问题是命令sh startup-config
的输出以这种方式显示数据:
data\n
data\n
data\n
data\n
\n
moredata\n
moredata\n
moredata\n ....
使用\n\n
,我得到的输出仅包含信息的第一段。