467,219 Members | 1,304 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,219 developers. It's quick & easy.

Can't match one of the expressions in telnet session

I'm telnetting into a router. Apart from the fact I can't seem to
view the output when iniciating the session, I can't match one of the
expressions using Net::Telnet. I can telnet into the router manually
without a problem. I'm running a sniffer at the same time just to see
what's happening behind the scenes. The computer does an ARP request
looking for the router's direction, but that seems to be it. I don't
think any data actually gets passed to iniciate telnet. I'm using the
following code:

1. use Net::Telnet;
2. $telnet = new Net::Telnet ( Timeout=>10,
3. Errmode=>'die');
4. $telnet->open('192.168.0.1');
5. $telnet->waitfor('/login:$/i');
6. $telnet->print('admin');
7. $telnet->waitfor('/Password: $/i');
8. $telnet->print('admin');
9. $telnet->waitfor('/\$ $/i');
10. $telnet->print('?');
11. $output = $telnet->waitfor('/adsl> \$ $/i');
12. print $output;

After logging into the router manually, confirming the
"login/password", I receive the prompt(exactly as it is written,
including spaces:)

login:admin
Password: *****

Login successful
--> (There is a space after the arrow to the right)

Here is the error I'm receiving:

pattern match timed-out at telnet.pl line 9

Should I assume that the script is atleast making it to that point.
I'm referring to the confirmation of the "login/passord". Any help
would be appreciated. Thanks in advance.
Jul 19 '05 #1
  • viewed: 7877
Share:
2 Replies
john brown wrote:
9. $telnet->waitfor('/\$ $/i');
11. $output = $telnet->waitfor('/adsl> \$ $/i');

Login successful
--> (There is a space after the arrow to the right)


Line 9 says to wait for a dollar-sign and space.
Line 11 says to wait for "adsl> " and a dollar-sign and space.
The last line quoted above has two hyphens, a right-angle
bracket, and a space. No dollar sign.

Why are you waiting for a dollar sign if the prompt uses
an angle bracket?
-Joe
Jul 19 '05 #2
Joe Smith <Jo*******@inwap.com> wrote in message news:<qN75c.13032$Cb.304070@attbi_s51>...
john brown wrote:
9. $telnet->waitfor('/\$ $/i');
11. $output = $telnet->waitfor('/adsl> \$ $/i');

Login successful
--> (There is a space after the arrow to the right)


Line 9 says to wait for a dollar-sign and space.
Line 11 says to wait for "adsl> " and a dollar-sign and space.
The last line quoted above has two hyphens, a right-angle
bracket, and a space. No dollar sign.

Why are you waiting for a dollar sign if the prompt uses
an angle bracket?
-Joe


Joe,
Good damn question? The original script was written to wait for a
"bash$"
prompt. I edited the script, but didn't catch that. Sometimes after
'/.m\$ ..?##/\\//\ $i /' things can get a little confusing. I'll try
it again. Thanks alot.
Jul 19 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Tom Lynn | last post: by
2 posts views Thread by Christian Wilcox | last post: by
3 posts views Thread by Yannick Turgeon | last post: by
4 posts views Thread by mark | last post: by
5 posts views Thread by Greg Martz | last post: by
3 posts views Thread by michael sorens | last post: by
13 posts views Thread by Godzilla | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.