472,811 Members | 1,871 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,811 software developers and data experts.

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
2 8209
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Tom Lynn | last post by:
I'm considering using a PHP command line script to retrieve reports from a Linux system. My only source for the report is via telnet. Has anybody here used fsockopen() to interactively script a...
2
by: Christian Wilcox | last post by:
I'm trying to programmatically access information from a telnet session which is normally accessed with a telnet program capable of terminal emulation (currently set at VT320). The initial login...
3
by: Yannick Turgeon | last post by:
Hello all, I'm currently trying to pass commands to a telnet session and get the texte generated (stdin + stdout) by the session. The problem I get is that the Telnet.read_until() function...
4
by: mark | last post by:
i am attempting to write a script using Net::Telnet. The script telnets to a machine logs in and issues a command to list the config. Tthe output of the command pauses about every screenfull...
5
by: Greg Martz | last post by:
I'd like to do the following in C# and prefer using tcpclient rather than raw sockets... Connect to a unix box Login run date +%H%M%S retrieve the response. That's it, nothing more. This...
3
by: michael sorens | last post by:
I have searched extensively and have found only hints of what is needed so far: What I want to do is open a telnet session to a remote host on a given port, login, execute a simple command, and...
1
by: juan | last post by:
Hello, I am new in Perl programming and I have to do some application quick. What I need is to do a telnet to a machine, this machine is sending continously values in columns with a format...
2
Bhanu Murthy
by: Bhanu Murthy | last post by:
I have Win2000 Server having 30 clients. I wanted to configure the server for Remote access with telnet application. I configured the server. But still I am not getting connected from the Client...
13
by: Godzilla | last post by:
Hello, How do you create/spawn new processes in XP over telnet using python? I.e. I would like to create a new process and have it running in the background... when I terminate the telnet...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Sept 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
14
DJRhino1175
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: lllomh | last post by:
How does React native implement an English player?
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.