Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine

Unable to get Net::Telnet::Cisco to connect to router

by Anonymous Monk
on Nov 13, 2003 at 22:45 UTC ( #306957=perlquestion: print w/replies, xml ) Need Help??

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

I am trying to the Net::Telnet::Cisco module to connect to my router. However, I am unable to get it to work. Typically I connect to my router with the following command.
telnet foo 2011
The console port of the router is connected to a term server. foo is the hostname for the term server and 2011 is the port that is connected to.

Here is some simple code that I can't get to work. What am I doing wrong??

use Net::Telnet::Cisco; my $session = Net::Telnet::Cisco->new(Host => 'foo', Port => 2011); # This is just a simple cmd to see if it ever works my @output = $session->cmd('sh clock'); print @output; $session->close;
I can't believe I am having this much difficultly for something so simple.

Replies are listed 'Best First'.
Re: Unable to get Net::Telnet::Cisco to connect to router
by shockme (Chaplain) on Nov 13, 2003 at 22:58 UTC
    I'm not sure why that's not working. Here's a sample from a script which does work:
    my $SwitchIP = ''; my $password = 'seekrit'; my $t = new Net::Telnet::Cisco (Timeout => 10, Dump_log => 'dump.log', Input_log => 'input.log', Port => 2011, ); $t->open("$SwitchIP"); $t->login(Password => $password);
    Hope that helps.

    Update: I think see why your script isn't working. According to the Net::Telnet::Cisco docs, you need to issue a login command:

    my $session = Net::Telnet::Cisco->new(Host => ''); $session->login('login', 'password');
    Your script seems to be correctly setting up the session, but you're issuing commands before you've logged into the router.

    If things get any worse, I'll have to ask you to stop helping me.

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://306957]
Approved by chromatic
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (5)
As of 2022-12-07 14:20 GMT
Find Nodes?
    Voting Booth?

    No recent polls found