Subject: | No timeout_hook parameter to override the "useless" default |
If one wants to deal with timeouts, for the moment, the only solution is
to use eval.
As it's so easy to add a timeout_hook option to the constructor, I
hacked this in. Tested on perl 5.12.4
Subject: | Expect.pm |
Message body is not shown because it is too large.
Subject: | Expect.diff |
diff --git a/Expect.pm b/Expect.pm
index efb38c0..5f82f73 100644
--- a/Expect.pm
+++ b/Expect.pm
@@ -5,7 +5,7 @@ use strict;
use fields qw(
host user password port no_terminal escape_char ssh_option
raw_pty exp_internal exp_debug log_file log_stdout restart_timeout_upon_receive
- timeout terminator expect debug next_line before match after binary
+ timeout timeout_hook terminator expect debug next_line before match after binary
);
use Expect;
use Carp;
@@ -44,6 +44,7 @@ sub new {
$self->{log_file} = $args{log_file} || undef;
$self->{log_stdout} = $args{log_stdout} || 0;
$self->{restart_timeout_upon_receive} = $args{restart_timeout_upon_receive} || 0;
+ $self->{timeout_hook} = $args{timeout_hook} || undef;
# Attributes for this module
$self->timeout(defined $args{timeout} ? $args{timeout} : 1);
@@ -204,7 +205,7 @@ sub login {
[ $password_prompt => sub { $exp->send("$password$t"); } ],
[ $login_prompt => sub { $exp->send("$user$t"); exp_continue; } ],
[ qr/REMOTE HOST IDEN/ => sub { print "FIX: .ssh/known_hosts\n"; exp_continue; } ],
- [ timeout => sub
+ [ timeout => $self->{timeout_hook} || sub
{
croak SSH_AUTHENTICATION_ERROR . " Login timed out. " .
"The input stream currently has the contents bellow: " .