X-Git-Url: http://git.rot13.org/?p=dell-switch;a=blobdiff_plain;f=dell-switch.pl;h=82debdaedb3074ce69bf4d348cc57e321b2edb5e;hp=6ca957ba0c8532441007ddaeaf6105138ee701a9;hb=HEAD;hpb=8656829ea0b6304fe634926be2f54535eb0c9cfd diff --git a/dell-switch.pl b/dell-switch.pl index 6ca957b..485d29c 100755 --- a/dell-switch.pl +++ b/dell-switch.pl @@ -99,7 +99,8 @@ while() { } elsif ( $buff =~ m/Password:/ ) { send_pty "$passwd\n"; $buff = ''; - } elsif ( $buff =~ m/[\n\r\b]([\w\-\(\)]+)#\s*$/ ) { + } elsif ( $buff =~ m/[\n\r\b]([\w\-\(\)\/]+)#\s*$/ ) { + # config interface needs / in prompt my $hostname = $1; if ( $buff ) { save_log $ip, $hostname, $command, $buff; @@ -116,10 +117,24 @@ while() { } } elsif ( $buff =~ m/% Unrecognized command/ ) { exit 1; + } elsif ( $buff =~ m/% Invalid input detected at .* marker/ ) { + + # try to rewrite command differences + + if ( $command =~ m/show lldp neighbors/ ) { + unshift @commands_while, 'show lldp remote-device all'; + undef $command; # don't save this command + $buff = ''; + } + + warn "# commands_while = ",dump( \@commands_while ); + } elsif ( $buff =~ s{More: , Quit: q.*One line: \s*}{} ) { send_pty " "; } elsif ( $buff =~ s{\Q--More-- or (q)uit\E}{} ) { send_pty " "; + } elsif ( $buff =~ s{\r\s{18}\r}{} ) { + # strip spaces delete after more prompt } elsif ( $buff =~ s{\e\[0m\s*\r\s+\r}{} ) { # nop } elsif ( $buff =~ m/^[\r\n]+[\w\-]+>$/ ) {