daphnaw has asked for the wisdom of the Perl Monks concerning the following question:
If the user entered the wrong username and/or password, I'd like to alert this without getting : SSHConnectionAborted at test.pl line 779. I've tried checkig the login_output , wrapping it with 'eval', catching before/after, with no success. The weird thing is that the line where it aborts is after the login:my $ssh; foreach (1..3) { eval { $ssh = Net::SSH::Expect->new( host => $host, password => $password, user => $user, raw_pty => 1, timeout => 3, binary => $ssh_exec, ); }; last if $ssh; sleep 1; } die "Could not connect to remote host '$host'\n" if not $ssh; my $login_output = $ssh->login;
Any ideas?$ssh->exec("stty raw -echo"); my $resp_uname = $ssh->exec('uname'); #This is line 779
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: How to catch/avoid SSHConnectionAborted
by salva (Canon) on Nov 15, 2010 at 13:08 UTC | |
by daphnaw (Acolyte) on Nov 15, 2010 at 14:35 UTC | |
by salva (Canon) on Nov 15, 2010 at 15:39 UTC | |
by daphnaw (Acolyte) on Nov 16, 2010 at 10:25 UTC | |
by mjscott2702 (Pilgrim) on Nov 15, 2010 at 15:24 UTC | |
by daphnaw (Acolyte) on Nov 16, 2010 at 08:28 UTC |