Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

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

by ArifS (Beadle)
on Oct 21, 2014 at 14:40 UTC ( [id://1104572]=note: print w/replies, xml ) Need Help??


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

I have modified the code as following-
use Net::Telnet::Cisco; my $cs = Net::Telnet::Cisco->new( Host => '10.10.1.1', Port => '7012', Prompt => '/(?m:^\W?[\w\/\d.:-]+[>#])/', Dump_Log => 'cisco.log', ); $username = "user"; $password = "pass"; $cs->waitfor_pause(1); $cs->print($username); print "user logged\n"; $cs->waitfor_pause(1); $cs->print($password); print "went thru\n"; # Execute a command my @cmd_output = $cs->cmd( 'show ver | inc Configuration' ); print @cmd_output; $cs->close;
Getting error:-
user logged went thru command timed-out at c:\temp\dirA9AB.tmp\telnet-2-port-test.pl line 23 Press any key to continue . . .
line 23: my @cmd_output = $cs->cmd( 'show ver | inc Configuration' );
Please let me know.

Replies are listed 'Best First'.
Re^3: Net::Telnet::Cisco - command timed-out error
by soonix (Canon) on Oct 22, 2014 at 09:04 UTC
    print "user logged\n";
    actually, that is a lie, that should read
    print "username sent without checking if the Cisco wanted it at all";
    and likewise for
    print "went thru\n";

    You did set dump_log, so Net::Telnet::Cisco should have logged what the remote device sent. What does cisco.log contain?

    Update/explanation: despite its name, waitfor_pause does not wait for anything, just sets a time for ->waitfor()

      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.

        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.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (9)
As of 2024-03-28 09:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found