|
Posted by Jim Gibson on April 12, 2007, 3:16 pm
Please log in for more thread options
> Hello,
> I am looking at a code fragment that I dont understand properly.
> ..
> my ($prematch, $match) = $telnet->waitfor('/login: $i);
I think you need '/login: $/i' there.
> $telnet->print($user);
> if (($prematch, $match) =$telnet->waitfor(string=> 'Choose a new
> password'))
> {
> crash out - cannot go on
> }
> my ( $prematch, $match) = $telnet->waitfor('/password: $/i);
> my($prematch, $match) = $telnet->print($password);
> ...
>
> So what I do understand is line1 we wait for "login: " case
> insensitive.
> Then line2 supply the user - ($prematch, $match) not used at this
> point.
> line 3 - i am not really sure - $prematch contains the match up to
> expression and $match the match expression but what is the if
> statement comparing?
> And how if we dont get the 'Choose new password' do we continue to
> provide the password?
My guess: check for a Timeout parameter in the call to new(). Also
check for a Errmode parameter or a call to errmode. My guess is that
your call to waitfor(string=>'Choose ...') is timing out and proceeding
to the next call (waitfor('/password: $/i');)
Note: it helps if you post a complete, minimal program so we don't have
to guess at what is going on.
>
> Actually I need to extend this program to do very similar things - is
> there an alternative way of doing this?
There is the Expect program:
<http://en.wikipedia.org/wiki/Expect> <http://search.cpan.org/~rgiersig/Expect-1.20/Expect.pod>
or the Perl Expect.pm module:
<http://search.cpan.org/~rgiersig/Expect-1.20/Expect.pod>.
Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com
|