473,847 Members | 1,721 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

telnet to router

14 New Member
Dear all,
I have written following script to loin to router bu it is showing error.

Expand|Select|Wrap|Line Numbers
  1. #!c:\Perl\bin;
  2. use strict;
  3. use warnings;
  4.  
  5.  my $hostname = 'REMOVED FOR YOUR PROTECTION';
  6.  my $password = 'REMOVED FOR YOUR PROTECTION';
  7.  
  8. use Net::Telnet();
  9.  my $telnet = new Net::Telnet ( Timeout=>40,Errmode=>'die');
  10. $telnet->open($hostname);
  11. $telnet->waitfor('/Password: $/i');
  12. print ("printing password");
  13. $telnet->print($password);
  14. $telnet->waitfor('/Router> $/i');
  15. print ("getting admin rights");
  16. $telnet->print('en');
  17. $telnet->waitfor('/Password: $/i');
  18. $telnet->print($password);
  19. print ("printing password");
  20. $telnet->waitfor('/Router#: $/i');
  21.  
Can't locate object method "new" via package "Net::Telne t" (perhaps you forgot t
o load "Net::Telne t"?) at h.pl line 9.


pls help me to rectify the problem
Sep 13 '09 #1
17 7352
numberwhun
3,509 Recognized Expert Moderator Specialist
@ravimath
Try removing the parenthesis after the module name, as such:

Expand|Select|Wrap|Line Numbers
  1. use Net::Telnet;
  2.  
They are not needed and are probably causing your problem.

Also, please do not include sensitive information in your posts (such as login information and IP Addresses). That is a security risk that you should always be wary of. I have removed them for you in your post.

Regards,

Jeff
Sep 13 '09 #2
ravimath
14 New Member
I have tried removing parenthesis, but still it gives same error.
thanks for your help
Sep 18 '09 #3
KevinADC
4,059 Recognized Expert Specialist
Did you properly install the Net::Telnet module? Your code is right out of the modules example code so that shouldn't be the problem, so maybe the module installation wasn't done properly.
Sep 18 '09 #4
ravimath
14 New Member
can u tell me how to check whether i have installed install the Net::Telnet module properly or not ? rather tell me how to install install the Net::Telnet module.
Sep 18 '09 #5
numberwhun
3,509 Recognized Expert Moderator Specialist
@ravimath
All the questions you have asked can be answered in the CPAN FAQ. It has a lot of good information. You can also find out how to figure out what modules are already installed.

Regards,

Jeff
Sep 18 '09 #6
ravimath
14 New Member
I have read cpan.faq , but it is not having sufficient info , regarding net::telnet installation on windows platform using ppm or any other method
can u tell me how to check whether i have installed install the Net::Telnet module properly or not ? rather tell me how to install install the Net::Telnet module.
pls help
Sep 21 '09 #7
ravimath
14 New Member
i have resolved following problemCan't locate object method "new" via package "Net::Telne t" (perhaps you forgot t
o load "Net::Telne t"?) at h.pl line 9., but now when i run that original script
it waits for getting input and after getting input it gives following error
'sfddg' is not recognized as an internal or external command,
operable program or batch file.
when i type something it shows nothing on screen , but it takes input.
even when i run another small script which includesonly one line
print $wkday;
it just returns to command prompt and does not show anything on screen

2)can u suggest some modifications, i want to achieve following
It should prompt for ip address of router , then ask for username , password and enable password and finally it should give output on screen of sh run of that router
Sep 21 '09 #8
numberwhun
3,509 Recognized Expert Moderator Specialist
@ravimath
For the modifications in #2, that should be quite simple for you to add. Why not try and post your code if you get stuck. Its just a simple matter of prompting the user and storing the answer(s).

Regards,

Jeff
Sep 21 '09 #9
ravimath
14 New Member
Expand|Select|Wrap|Line Numbers
  1. #!c:\Perl\bin; 
  2. use strict; 
  3. use warnings; 
  4.  
  5.  my $hostname = 'REMOVED FOR YOUR PROTECTION'; 
  6.  my $password = 'REMOVED FOR YOUR PROTECTION'; 
  7.  
  8. use Net::Telnet(); 
  9.  my $telnet = new Net::Telnet ( Timeout=>40,Errmode=>'die'); 
  10. $telnet->open($hostname); 
  11. $telnet->waitfor('/Password: $/i'); 
  12. print ("printing password"); 
  13. $telnet->print($password); 
  14. $telnet->waitfor('/Router> $/i'); 
  15. print ("getting admin rights"); 
  16. $telnet->print('en'); 
  17. $telnet->waitfor('/Password: $/i'); 
  18. $telnet->print($password); 
  19. print ("printing password"); 
  20. $telnet->waitfor('/Router#: $/i'); 
  21.  
I have already added this code pls suggest changes for my previous question
Sep 22 '09 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

6
6478
by: Richard Bird CCNP, CCDP, MCSE, etc. | last post by:
I need some help adding multithreading to an existing python script. The script was developed to telnet and make changes on a list of cisco routers. I figure that by adding multithreading, I'd be able to telnet to several routers concurrently and speed up the process of making changes. Is this feasible using python with its standard telnet lib?
2
8284
by: john brown | last post by:
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...
2
3070
by: newsf | last post by:
Hi, I want to make a program what connect through telnet protocol to a router, and run commands for configure the router. I read over sockets and I made the program above, but it don´t work fine. After this, I read document in Internet about this, and I believe that I have to implement the protocol. But I don´t know. Someone can help me.
3
1475
by: Lidvar | last post by:
Hi. I wonder if anyone know a easy way to control a ISDN router in telnet, in visual basic..?
2
2961
by: _andrea.l | last post by:
I'm writing a little script for reading information from a router by telnet. I have a problem How give a comand and get the answer more times? I means: $usenet = fsockopen($cfgServer, $cfgPort, &$errno, &$errstr, $cfgTimeOut);
0
3125
by: mario.lat_ | last post by:
Hallo to all, I have write a little script for connecting to cisco router BUT I have a problem: I have to send to router all the commands and then I have to read the output. If I send a command1 and read the output for command1 the script works well, If I sent command1 , I send command2 and then I read output for command1 and command2 it works well. If i send command1 and then I read the output for command1 then send command2 I can't...
2
7728
by: vmalhotra | last post by:
Hi I am new in python scripting. I want to open a Multiple telnet session through once script. In other way i can tell i want to open two linux consoles through one script. I wrote one script, but the issue is I am not able to open multiple consoles. The Scripts which i wrote is as follows: import pexpect
3
4258
by: svjames | last post by:
Hey guys, im working on a project that requires a telnet connection to be made from a web page to a router, auto login then quit/drop whatever, its just gotta run one and in the background. my friend wrote me this code because i know nothing about java but i cant even begin to imagine how to make this thing run. Ive tried useing html tags like inserting a java applet but this seems not to work. I know it would be much more respectable to sit...
2
4578
by: manuitpro | last post by:
Hi, I have implemented a php script by which i can login to a router using fsockopen(), and i can run any cisco commands. But i have requiremnt login to a remote from from a central router for the out of band management. How can make a script by whch i can login to another cisco router (telnet) from an already logged in router. my script has a class and functions.
0
9882
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
9727
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
10982
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...
0
10645
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9481
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
5719
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5909
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4524
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
3160
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.