X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=include%2Fios.pm;h=b6ba7f40f25cc482b468ca72cc6e3b7416dd4370;hb=d729a00cf5572a2ee1a651d9bcceb5750715bd0b;hp=750a96ba49df9bb743e1cc6027c6ad18b2f6abb3;hpb=31834d967b81557a519d32c881d0fc42fe11dfee;p=nms diff --git a/include/ios.pm b/include/ios.pm index 750a96b..b6ba7f4 100644 --- a/include/ios.pm +++ b/include/ios.pm @@ -6,6 +6,9 @@ use Net::Telnet; package nms; +use base 'Exporter'; +our @EXPORT = qw(ios_waitprompt ios_enable ios_login ios_connect ios_close); + my $iosprompt = '/[^\s]+[#>]/'; sub ios_waitprompt($) { @@ -19,13 +22,15 @@ sub ios_waitprompt($) { #print "PRE: $prematch\nM: $match\n"; } -sub ios_enable($$) { +sub ios_enable { my ($t, $enablepass) = @_; print STDERR "Enabling...\n"; my @lines = $t->print("enable"); - $t->waitfor('/Password: /'); - $t->print($enablepass); + if ($enablepass) { + $t->waitfor('/Password: /'); + $t->print($enablepass); + } ios_waitprompt($t); } @@ -44,11 +49,14 @@ sub ios_login($$$) { ios_waitprompt($t); } +use Data::Dumper; + sub ios_getroute { my ($t, $net) = @_; my @output = $t->cmd("show ip route".($net ? " $net" : '')); + print Dumper(@output); foreach (@output) { return 0 if $_ =~ /^% Network not in table/; }