I have recently been made aware of Net::Telnet and ::Cisco modules which are pretty handy for telneting to a device.

My problem lies in that im trying to use Perl (for automation) to telnet to a line on a 2511 Access Server, a line that contains a directly connected device.

For instance:

####BEGIN CODE
#!/usr/bin/perl no strict; #### Define Library Locations ### #use lib '/root/Net-Telnet-3.03/blib/lib/Net/';use lib '/root/Net-Teln +et-Cisco-1.10/blib/lib/'; #### Define Modules to use #### use Net::Telnet::Cisco; #### Create Telnet Connection to Device#### my $telnet = Net::Telnet::Cisco->new(Host=>'1.2.3.4 2005', Timeout=>2, Errmode=>'die'); $telnet->waitfor('/Username:/') or die('FAILED'); $telnet->print('xxxx'); $telnet->waitfor('/Password:/') or die('FAILED'); $telnet->print('xxxx'); #$telnet->send_wakeup('connect'); $telnet->waitfor('/PROMPT>/'); @output = $telnet->cmd('show ver'); print @output;
####END CODE

Someone mentioned they thought I needed a colon between the IP and LINE of the device (e.g. 1.2.3.4:2005 instead of 1.2.3.4 2005). I use a space whenever I telnet via a shell prompt and it works.

The odd thing is that when I use the script above and issue "cmd('show ver')" the output is a 'show ver' of the 2511 and not the device connected. Its like im connected to the 2511 and not the device.

I've used both ::telnet and ::cisco but both produce the same result. It's as though perl's interpretation of telnet is different than that of which i type from a shell prompt.

Am i really missing something? I ask because you guys are the masters, im the schoolboy.

Any help is greatly appreciated,

Edit by tye: Add CODE tags


In reply to Telneting to a 2511 Access Server Device on line 2005 by llod45

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.