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

I'm trying to use Net::Appliance::Session to establish a connection to a cisco console server (cisco 2600). If I Telnet directly to the device without the 'Port' setting the interaction works as expected, but if I attempt to connect to a console server and a specific port for the device it doens't work.

I think the issue may be related to the console's need for an extra carriage return<CRLF> to bring up the password prompt, that isn't necessary when I telnet directly to the device.

my $session_obj = Net::Appliance::Session->new( Host => $cisco_console_server, Transport => 'Telnet', Port => '2033', );


linux_prompt#telnet cisco_console_server 2033
Trying 10.2.200.10...
Connected to 10.2.200.10.
Escape character is '^]'.

Password:

linux_prompt# telnet device
Trying 10.2.200.101...
Connected to 10.2.200.101.
Escape character is '^]'.
Password:

Thanks in advance for any ideas about settings for the console server, or settings for Net::Telnet or Net::Appliance::Session or what else might solve this issue.

Replies are listed 'Best First'.
Re: Net::Appliance::Session and Console Server
by desemondo (Hermit) on Mar 06, 2010 at 01:07 UTC
    Could be a number of things... In short, you might need to provide a bit more info...

    1. If I Telnet directly to the device without the 'Port' setting the interaction works as expected
    Could you clarify exactly what you mean by that? And what appears different between the them...

    2. You could try sniffing with Wireshark for what is actually being sent, and compare it with what you get with a direct connection and/or comparing to what you get with a shell telnet connection.

      1)a)If I telnet directly to port 23 on the actual device the Password prompt is immediately displayed.
      telnet 10.2.200.101 Trying 10.2.200.101... Connected to 10.2.200.101. Escape character is '^]'. Password:
      1b)If I telnet to the console server and the port on the console server that is connected to the console port on the device I have to hit return before I see the Password: prompt.
      telnet 10.2.200.10 2033 Trying 10.2.200.10... Connected to 10.2.200.10. Escape character is '^]'. (I HAVE TO HIT RETURN HERE TO GET THE PROMPT) Password:
      I also tested this out with Net::Telnet::Cisco and was able to prove the theory by using $session_obj->send_wakeup('connect');

      So I guess my question now is, how can I send that wakeup or carriage return inside Net::Appliance::Session (which is using Net::Telnet as the transport module).
Re: Net::Appliance::Session and Console Server
by Khen1950fx (Canon) on Mar 07, 2010 at 08:30 UTC
    I read your post yesterday, but at that time, the question wasn't clear to me. I came back to it today. Ok..I think that I can see what happened. Try it like this:
    #!/usr/bin/perl use strict; use warnings; use Net::Appliance::Session; my $session_obj = Net::Appliance::Session->new( Host => $cisco_console_server, Transport => 'Telnet', ); $session_obj->connect( Name => 'user', Password => 'password', Opts => [ '-p', '2033', ] );
      Thanks for the suggestion, but that actually logs me into the terminal server IP address and not the terminal server + port. If I use wireshark to sniff the packets...Port => 2033 actually works as part of the new constructor. When I attempt to connect I see the traffic sent to 2033. If I use Opts during the connect method I don't see traffic sent to the correct port. I believe Opts is actually for SSH traffic and not Telnet traffic. Not sure where to go from here...
        Try dropping down to a REPL like:
        #!/usr/bin/perl use strict; use warnings FATAL => 'all'; use Net::Appliance::Session; $|=1; my $host = 'cisco_server' if (not defined $host); my $session_obj = Net::Appliance::Session->new( Host => $host, REPL => 1, ); $session_obj->connect( Name => 'user', Password => 'password', );