|
Hi,
I usually use expect_after and expect_before with expect to control timeout's and eof in
my scripts:
! /usr/bin/expect
spawn ssh manuel@linux01
set timeout 2
expect_before {
timeout {puts "timeout before"; exit}
}
expect_after {
eof {puts "eof after"; exit}
}
expect {
"assword: " {send "password"}
}
...
I tried something similar with expect.pm, but it doesn't work:
use strict;
use Expect;
my $exp = new Expect();
my @param=qw(root@linux);
$exp->spawn("ssh",@param) || die ("error en comando: $! \n");
$exp->exp_before( 'timeout', \&timeout);
$exp->exp_after( 'eof', \&eof);
$exp->expect(2,'-re',"bssword");
...
sub timeout {
print "algo por timeout\n";
exit;
}
sub eof {
print "algo por eof\n";
exit;
}
Why exp_before don't work like expect_before?
Regards
|