#!/usr/bin/perl
use Expect;
use strict;
my $device = $ARGV[0];
my $password = $ARGV[1];
my $enable_password = $ARGV[2];
my $timeout = 10;
my $command = Expect->spawn("telnet $device");
$command->log_stdout(0);
$command->expect($timeout, -re => "Password:") or die("Failed to get password prompt");
print $command "$password\r";
print $command "enable\r";
$command->expect($timeout, -re => "assword") or die("Did not get a password prompt\n");
print $command "$enable_password\r";
print $command "show log\r";
my $redo = 1;
while($redo)
{ $command->clear_accum();
$command->expect(1,
[ qr/More/ => sub { my $comand = shift; print $command "\r"; exp_continue; } ],
[ qr/#/ => sub { my $exp = shift; $redo = 0; exp_continue; } ],
);
}
print $command "exit\r";
$command->soft_close();
No luck getting SSH working... since I don't have any SSH based Ciscos at hand.
SSH on embedded hosts (Score:1)
But using Expect to drive a telnet or ssh session to a Juniper box works very well. I spoke to btrott at the time (this was about 5 years ago) he said that he didn't have time to maintain Net::SSH as best it deserved any more.
Re:SSH on embedded hosts (Score:1)