X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=dell-switch.pl;h=efff4ba71000d9322e275cf03609461aec259fda;hb=960ba866fea8370962ec8e6d91234ef16843ba05;hp=65cc0be0a918ea4c6c15fcdd84495cbb1ad3f617;hpb=bac91465d5f5848539deb9ce9145a97b884c9e84;p=dell-switch diff --git a/dell-switch.pl b/dell-switch.pl index 65cc0be..efff4ba 100755 --- a/dell-switch.pl +++ b/dell-switch.pl @@ -53,6 +53,7 @@ sub save_log { my ($ip, $hostname, $command, $buff) = @_; return unless $command; + return if $ENV{NO_LOG}; my $file = "${ip}_${hostname}_${command}.log"; open my $log, '>', $file; @@ -78,7 +79,7 @@ while() { } elsif ( $buff =~ m/Password:/ ) { send_pty "$passwd\n"; $buff = ''; - } elsif ( $buff =~ m/([\w\-]+)#$/ ) { + } elsif ( $buff =~ m/([\w\-\(\)]+)#$/ ) { my $hostname = $1; if ( $buff ) { save_log $ip, $hostname, $command, $buff; @@ -103,6 +104,11 @@ while() { # nop } elsif ( $buff =~ m/^[\r\n]+[\w\-]+>$/ ) { send_pty "enable\n"; + } elsif ( $buff =~ m{\QOverwrite file [startup-config] ?[Yes/press any key for no]....\E} ) { + send_pty "y"; + $buff = ''; + } elsif ( $buff =~ s{Management access will be blocked for the duration of the transfer.*Are you sure you want to start\? \(y/n\) }{}s ) { + send_pty 'y'; } }