Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re^4: Net::Telnet::Cisco - command timed-out error

by ArifS (Beadle)
on Oct 22, 2014 at 15:43 UTC ( [id://1104698]=note: print w/replies, xml ) Need Help??


in reply to Re^3: Net::Telnet::Cisco - command timed-out error
in thread Net::Telnet::Cisco - command timed-out error

Thank you for your reply. I think I can see the problem. When I try with working devices, it prompts for "Username: " and the script works. But the device that having the issue, require
1) an Enter 1st and then
2) prompt for "login: ".

That's where the device is timing out.
Any suggestion? Please let me know.
  • Comment on Re^4: Net::Telnet::Cisco - command timed-out error

Replies are listed 'Best First'.
Re^5: Net::Telnet::Cisco - command timed-out error
by soonix (Canon) on Oct 23, 2014 at 06:48 UTC

    Ah. I See. So you would have to send a "\n" or "\r" forst, and only then do the ->login().

    The author of Net::Telnet::Cisco seems to have anticipated this problem, there is a send_wakeup setting. You could modify the code from your OP to

    my $cs = Net::Telnet::Cisco->new( Host => '10.10.1.2', Port => '7012', + Send_wakeup => 'connect', Dump_Log => 'cisco.log', );
    (don't know, wether you need to set the prompt, you'll see for yourself)

    The effect is, that, upon connecting, a newline is sent upon connection. Perhaps this works even with devices that don't need it.

      With the Send_wakeup => 'connect', added my script times out and I get the following error-
      bad named parameter "Send_wakeup" given to Net::Telnet::Cisco::new() a +t
      Please let me know.

        Sorry, I know this module only from its doc and source, because we don't have that much Ciscos.

        The message "bad named parameter" isn't there, but in Net::Telnet. Obviously, Net::Telnet::Cisco->new gives all its input parameters to Net::Telnet->new without cleaning out its own extensions.
        Perhaps the error checking in Net::Telnet->new was put in later...

        Anyway, if you leave it out, and put instead
        $cs->send_wakeup('connect'); $cs->login(...);
        at least this doesn't give the error message.

        Update: tried it at work (no Cisco at home :-)), our cisco doesn't need send_wakeup, but works also with it. I tested using the following code

        use Net::Telnet::Cisco; my ($host, $user, $pass) = qw(10.10.1.1 user pass); my $cs = Net::Telnet::Cisco->new( Host => $host, Dump_Log => 'cisco.log', Prompt => '/(?m:^\W?[\w\/\d.:-]+[>#])/', ); $cs->send_wakeup('connect'); $cs->login( $user, $pass ); my @cmd_output = $cs->cmd( 'show ver | inc Configuration' ); print @cmd_output; $cs->close;

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1104698]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (3)
As of 2024-04-20 16:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found