Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

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:

Hi,

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->open("X.X.X.X");
$t->waitfor('/login: /');
$t->print($uname);
$t->waitfor('/Password: /');
$t->print($passwd);
$t->waitfor('/"Are you sure to continue\? (Y\/N)\? : "/');
$t->print("Y\n");
$t->waitfor('/Please hit <return> to continue /');
$t->print("\n");

But I am getting this error: " pattern match timed-out at jtry.pl " 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
Re: not able to reach to the prompt while using Net::Telnet
by vitoco (Pilgrim) 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?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://811900]
Approved by marto
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (7)
As of 2014-07-25 11:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (170 votes), past polls