From: Prashar <him...@ya...> - 2009-02-16 07:59:55
|
Hi, Snippet of code pasted below gets time-out as it couldnt match the string "[spr9628-c] MP>". Could some one please temme where actually I goofed up . $exp->expect($timeout, [ 'timeout' => sub{print "\nERROR: Timed out waiting for telnet to close.\n"; }], [ 'MP login: $', sub { $spawn_ok = 1; my $fh = shift; $fh->send("$username\n"); exp_continue; } ], [ 'MP password: $', sub { my $fh = shift; print $fh "$password\n"; exp_continue; } ], [ eof => sub { if ($spawn_ok) { die "ERROR: premature EOF in login.\n"; } else { die "ERROR: could not spawn telnet.\n"; } } ], [ '-re', '\s*MP Host Name:(.*)\r', sub { my $fh = shift; $tmp = ($fh->matchlist)[0]; ## $tmp = spr9628-c $tmp =~ s/\s+//g; $tmp =~ s/^\s+//g; exp_continue; } ], '-re', '\[$tmp\]\sMP>\s', ## Should exit expect from here as per logic ); ========================== Output: MP Host Name: spr9628-c Revision E.03.15 ************************************************************************* MP ACCESS IS NOT SECURE Default MP users are currently configured and remote access is enabled. Modify default users passwords or delete default users (see UC command) OR Disable all types of remote access (see SA command) ************************************************************************* MP MAIN MENU: CO: Console VFP: Virtual Front Panel CM: Command Menu CL: Console Log SL: Show Event Logs HE: Main Help Menu X: Exit Connection [spr9628-c] MP> ERROR: Timed out waiting for telnet to close. Thanks in advance -H -- View this message in context: http://www.nabble.com/Expect-perl-tp22032953p22032953.html Sent from the Perl - Expectperl-Discuss mailing list archive at Nabble.com. |