我制作了连接到我的交换机的脚本,但问题是当查看它时只显示部分内容,其余部分显示为大小(--更多)。我该怎么做才能查看所有配置,谢谢
use Net::OpenSSH;
use warnings;
use Expect;
my $password = 'admin';
my $enable = '';
my $ip = '192.16.25.39';
my $username='user';
my $ssh = Net::OpenSSH->new("$username:$password\@$ip", timeout => 200) ;
$ssh->error and die "unable to connect to remote host: ". $ssh->error;
my $output = $ssh->capture({stdin_data => "enable\n"."admin%\n"."show vlan"."\n"});
if ($output) {print $output . ' ';}
my $line;
print "\n";
# closes the ssh connection
$ssh->close();
我已经用 Expect 模块尝试过这个:
use Net::OpenSSH;
if ($output) {
print $output . ' ';
my $expect = Expect->init($output);
$expect->raw_pty(1);
#$expect->debug(2);
my $debug and $expect->log_stdout(1);
while(<$pty>) {
print "$. $_ "
}
}
产生此错误:
无法在 /usr/local/share/perl5/Expect.pm 第 202 行 (#1) (F) 祝福非参考值 (F) 只能祝福硬引用。这就是 Perl 如何“强制”封装对象。参见 perlobj。用户代码中未捕获的异常:Can't bless non-reference value at /usr/local/share/perl5/Expect.pm line 202. at /usr/local/share/perl5/Expect.pm line 202. Expect::exp_init ("期待", "\x{d}\x{a}witch>enable\x{d}\x{a}密码:\x{d}\x{a}switch#show vlan\x{d} \x{a}\x{d}\x{a}VLA"...) 在 b.pl 第 19 行调用"