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 ?
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.