|
From: John S. <j.d...@re...> - 2000-11-27 12:51:04
|
On Wed, 22 Nov 2000, Roland Giersig wrote:
> Seems like the FAQ didn't make it, so I'm resending it...
Hmmm, this example doesn't seem to work in 1.10 (though I had something
similar working OK in 1.08)
> How to automate login
$obj->expect($timeout,
[
qr'login: $',
sub {
my $fh = shift;
print $fh "$username\r"; exp_continue;
}
],
[
'Password: $',
sub {
my $fh = shift;
print $fh "$password\r"; exp_continue;
}
],
[
timeout =>
sub {
die "No login.\n";
}
],
'-re', qr'[#>:] $', #' wait for shell prompt, then exit
expect
);
Problem is, it doesn't exit after getting the shell prompt. Here's a bit of
the script's Exp_Internal dialogue:
...
Waiting for new data (9 seconds)...
shellprompt>
spawn id(4): Does `\r\nLast login: Mon Nov 27 12:31:32 from foo\r\nshellpromppt> '
match:
pattern #1: -re `(?-xism:login: $)'? No.
pattern #2: -re `Password: $'? No.
pattern #4: -re `(?-xism:[#>:] $)'? YES!!
Before match string: `\r\nLast login: Mon Nov 27 12:31:32 from foo\r\nshellprompt'
Match string: `> '
After match string: `'
Matchlist: ()
Continuing expect, restarting timeout...
spawn id(4): Does `'
match:
pattern #1: -re `(?-xism:login: $)'? No.
pattern #2: -re `Password: $'? No.
pattern #4: -re `(?-xism:[#>:] $)'? No.
Waiting for new data (9 seconds)...
TIMEOUT
Calling timeout function ARRAY(0xccfec)...
No login.
So it looks as if it successfully matches the shell prompt, but doesn't
exit.
regards,
--
John Stumbles j.d...@re...
I.T. Services Centre, University of Reading http://www.rdg.ac.uk/~visstmbl
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
never generalise
|