Net::Telnet $prematch, $match

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

I am looking at a code fragment that I dont understand properly.
my ($prematch, $match) = $telnet->waitfor('/login: $i);
if (($prematch, $match) =$telnet->waitfor(string=> 'Choose a new
  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
Then line2 supply the user - ($prematch, $match) not used at this
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?

Actually I need to extend this program to do very similar things - is
there an alternative way of doing this?



Re: Net::Telnet $prematch, $match

Quoted text here. Click to load it

I think you need '/login: $/i' there.

Quoted text here. Click to load it

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.

Quoted text here. Click to load it

There is the Expect program:

or the Perl module:

 Posted Via Premium Usenet Newsgroup Services

Re: Net::Telnet $prematch, $match

On 04/12/2007 09:18 AM, ton de w wrote:
Quoted text here. Click to load it

I'm assuming that the "errmode" is "return." When the second
$telnet->waitfor() succeeds, the method will return a list containing
values for $prematch and $match. If that happens, it means that the host
is demanding a new password, and since the script can't handle that, it
exits. The "if" statement tests whether a non-empty list was returned by

Quoted text here. Click to load it

Site Timeline