X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;ds=sidebyside;f=dell-switch.pl;h=82debdaedb3074ce69bf4d348cc57e321b2edb5e;hb=HEAD;hp=826b41e40d7768beb175b92014115491959310f2;hpb=d8cecd6d9b6a0ff463d20102e2632ca2b219efc9;p=dell-switch diff --git a/dell-switch.pl b/dell-switch.pl index 826b41e..485d29c 100755 --- a/dell-switch.pl +++ b/dell-switch.pl @@ -33,8 +33,14 @@ if ( ! @commands && ! -t STDIN && -p STDIN ) { # we are being piped into warn "\n## ssh $ip\n"; my $ssh = Net::OpenSSH->new($ip, user => $login, passwd => $passwd, ssh_cmd => '/usr/bin/ssh1', # apt-get install openssh-client-ssh1 - master_opts => [ -o => "StrictHostKeyChecking=no", ], - default_ssh_opts => [ -o => "StrictHostKeyChecking=no", ], + master_opts => [ + -o => "StrictHostKeyChecking=no", + -F => '/home/dpavlin/dell-switch/ssh1-config' + ], + default_ssh_opts => [ + -o => "StrictHostKeyChecking=no", + -F => '/home/dpavlin/dell-switch/ssh1-config' + ], ); my ($pty ,$pid) = $ssh->open2pty(); if ( ! $pty ) { @@ -93,7 +99,8 @@ while() { } elsif ( $buff =~ m/Password:/ ) { send_pty "$passwd\n"; $buff = ''; - } elsif ( $buff =~ m/([\w\-\(\)]+)#$/ ) { + } elsif ( $buff =~ m/[\n\r\b]([\w\-\(\)\/]+)#\s*$/ ) { + # config interface needs / in prompt my $hostname = $1; if ( $buff ) { save_log $ip, $hostname, $command, $buff; @@ -110,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\-]+>$/ ) { @@ -140,4 +161,3 @@ show vlan show running-config show bridge address show interfaces status -