Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?

not able to reach to the prompt while using Net::Telnet

by godsown (Novice)
on Dec 09, 2009 at 11:44 UTC ( #811900=perlquestion: print w/replies, xml ) Need Help??
godsown has asked for the wisdom of the Perl Monks concerning the following question:


I am new to Perl and currently trying to create a Telnet session using Net::Telnet.

Usually after providing the username and passwd, the system prints a banner and at the end of it is a question ("Are you sure to continue? (Y/N)? : "). Only on answering a yes to that question, I can login to the system. Also after giving the yes, followed by 'pressing of enter key on keyboard', i again have to press the enter key one more time to finally get to the shell prompt.

Now, while using the Net::telnet, i am able to provide the login and passwd.. but I am not sure how to provide the 'Y' to the question followed by pressing of enter key, followed by another press of enter key.. I currently m using the following:

my $t = new Net::Telnet (Timeout => 10);
$t->waitfor('/login: /');
$t->waitfor('/Password: /');
$t->waitfor('/"Are you sure to continue\? (Y\/N)\? : "/');
$t->waitfor('/Please hit <return> to continue /');

But I am getting this error: " pattern match timed-out at " this is occuring at the third waitfor() call.

Please let me know what wrong am I doing here ? Any other suggestion ?
  • Comment on not able to reach to the prompt while using Net::Telnet

Replies are listed 'Best First'.
Re: not able to reach to the prompt while using Net::Telnet
by vitoco (Friar) on Dec 09, 2009 at 12:06 UTC

    Try this:

    $t->waitfor('/"Are you sure to continue\? \(Y\/N\)\? : "/');

    UPDATE: Are quotes being displayed on a terminal session? If not, try:

    $t->waitfor('/Are you sure to continue\? \(Y\/N\)\? : /');

    Is any artifact in use like bold, blinking or colored text? Then, you must add some wildcards somewhere to match escape sequences.

      the actual message does not contain quotation marks.. but even wen i try without the quotations, it fails at the same line with same error: "pattern match timed-out"..
Re: not able to reach to the prompt while using Net::Telnet
by jeffreyray (Sexton) on Dec 09, 2009 at 14:30 UTC
    I've been there. You will find that sometimes you are actually getting more back from the server than is displayed in the console of telnet session.

    Check out the Net::Telnet documentation on debugging. The input_log option will help you figure out what data you actually received vs. what you usually see in a console.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://811900]
Approved by marto
and the universe expands...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (10)
As of 2018-06-25 12:41 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (126 votes). Check out past polls.