473,695 Members | 2,621 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 8272
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*******@inwa p.com> wrote in message news:<qN75c.130 32$Cb.304070@at tbi_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
13467
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 telnet session in PHP? If so, what problems did you have to overcome. If not, does this sound do-able?
2
3971
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 text displays fine, of course, but when I get to the section which displays extended ASCII characters, Telnet from telnetlib displays the following garbled mess: ?[?40h?[?3l?[0;1m?>?[?1l?[?25l?[?3l?[0;0H?[2J?[?25l?(B??[0;7m?[23B ba6.0 version...
3
8659
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 seems to freeze after a couple of command. I did a simplify script that reproduce the problem each time (I'm using 2.3.4 on W2K):
4
5102
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 and gives the user the prompt " --More-- ". The script contains the followin code to account fot the prompt. $telnet->waitfor('/-\-More\-\- $/i'); $telnet->print('\s');
5
33862
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 shouldn't be too complicated, I thought... I have yet to find any examples of being able to do this.
3
5055
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 retrieve the results. The TcpClient class documentation provides a nice example, but it does not work for telnet... I suspect there is more to the negotiation for telnet than just the generic TCP client they present in the sample. I am hoping...
1
1611
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 timestamp channel1 channel2 channel3 channel4 (e.g: 20060620 22:10:00 2.333 1.565 7.000 2.333) 20060620 22:10:01 2,444 1.222 2.22 3.000) so I want to open the telnet session, and pass the values into a DB. I know how to open the telnet...
2
4254
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 (Win Me O/s). It displays connection failed with a message displaying NTLM authentication is required. (when I tested on the server, server is able to respond with telnet command - which means server is configured with telnet and the session is...
13
3152
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 connection, I would what the spawned processes to keep running until I shut it off... I got the os.popen method to spawn a new process running in the backgroun, but not over telnet... tried os.popen and also subprocesses.popen without any luck...
0
8647
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8585
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9132
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8864
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7682
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5842
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4592
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3024
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
1986
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.