X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=dell-switch.pl;h=e3c3b0d74af7179533c0e6252f26e49288d9c4d3;hb=8e5fcc0e9db472b21d3d21b0882a8c469b2f575d;hp=9b0c3f723c552fd4498a252326109e0574ebb146;hpb=a15f54b1b5714dd8dbd75109e27d3eb3e17839cf;p=dell-switch diff --git a/dell-switch.pl b/dell-switch.pl index 9b0c3f7..e3c3b0d 100755 --- a/dell-switch.pl +++ b/dell-switch.pl @@ -17,11 +17,12 @@ require 'config.pl'; #$Net::OpenSSH::debug = ~0; my $ip = shift @ARGV || die "usage: $0 IP command[ command ...]\n"; +$ip = $1 if `host $ip` =~ m/has address (\S+)/; my @commands = @ARGV; @commands = unless @commands; warn "\n## ssh $ip\n"; -my $ssh = Net::OpenSSH->new($ip, user => $login, passwd => $passwd); +my $ssh = Net::OpenSSH->new($ip, user => $login, passwd => $passwd, default_ssh_opts => [-o => "StrictHostKeyChecking=no"]); my ($pty ,$pid) = $ssh->open2pty(); if ( ! $pty ) { warn "ERROR: can't connect to $ip, skipping"; @@ -32,12 +33,12 @@ my $buff; sub send_pty { my $string = shift; - sleep 0.1; # we really need to wait for slow PowerConnect 5324 + sleep 0.05; # we really need to wait for slow PowerConnect 5324 foreach (split //, $string) { print STDERR "[$_]" if $debug; syswrite $pty, $_; #$pty->flush; - sleep 0.05; + sleep 0.01; sysread $pty, my $echo, 1; print STDERR $echo; @@ -107,6 +108,8 @@ while() { } 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'; } }