10 our @EXPORT = qw(ios_waitprompt ios_enable ios_login ios_connect ios_close);
12 my $iosprompt = '/[^\s]+[#>]/';
14 sub ios_waitprompt($) {
17 #while ($t->getline) {
18 # print "Line: $_\n" if $_;
21 my ($prematch, $match) = $t->waitfor($iosprompt);
22 #print "PRE: $prematch\nM: $match\n";
26 my ($t, $enablepass) = @_;
28 print STDERR "Enabling...\n";
29 my @lines = $t->print("enable");
31 $t->waitfor('/Password: /');
32 $t->print($enablepass);
38 my ($t, $user, $pass) = @_;
40 print STDERR "Waiting username\n";
41 my ($prematch, $match) = $t->waitfor('/Username:\s{0,}/');
42 print STDERR "Sending username\n";
44 print STDERR "Waiting password\n";
45 ($prematch, $match) = $t->waitfor('/Password: /');
46 print STDERR "Sending password\n";
57 my @output = $t->cmd("show ip route".($net ? " $net" : ''));
59 print Dumper(@output);
61 return 0 if $_ =~ /^% Network not in table/;
68 my ($host, $user, $pass, $enablepass) = @_;
70 my $t = new Net::Telnet(Timeout => 15,
71 Prompt => $iosprompt);
72 $t->dump_log("/tmp/ios.log");
74 ios_login($t, $user, $pass);
75 ios_enable($t, $enablepass) if $enablepass;
76 $t->cmd("terminal length 0"); # Don't use the pager