I would like to start by saying that I cannot use Net::Telnet::Cisco due to constraints on installing software on the machine in question.

I have a weird issue when talking to my Cisco devices using Net::Telnet - but only when I am running "enabled" within the router. Code:

#!/usr/bin/perl -w use strict; use Net::Telnet; my $t = new Net::Telnet( Input_log => 'log.txt', Prompt => '/cis-.+[>#]/' ); ## Note - all my Cisco devices have hostnames beginning with "cis-" ## so hence the custom prompt setting here. $t->open('10.10.10.1'); $t->login('username1', 'password1'); $t->cmd('term length 0'); print $t->cmd('where'); ## Everything above this line works as I expect ## Things below this line seem to go a bit weird... $t->print('enable'); $t->waitfor('/Password:/'); $t->print('password1'); $t->cmd('term length 0'); print $t->cmd('where'); $t->close();

Now, any command issued before the "enable", as the regular user, works and output is as expected. I've used "where" here as it's pretty universal but under some devices you can also "sh version" as a normal user. Basically, the result of running that line is the printing of the output as expected.

I have also proved that the elevation from regular user to enabled super-user works.

The problem seems to occur in the code AFTER I do the "enable". For example, the code as displayed does NOT print the output of the "where" command after enabling. Replace this with anything else that produces output (such as "sh ver" or "sh run" or something) and still nothing. HOWEVER... if a second "print $t->cmd..." command is added after the enabling, then the output of the FIRST enabled command gets printed after the SECOND enabled command has run.

As you can see, I also capture the input from the device into a file (log.txt in this case) and the contents of that file agrees with what I see on the screen.

Can someone please suggest where I could be going wrong here?.....

fx, Infinity is Colourless


In reply to Cisco weirdness under Net::Telnet when "enabled" by fx

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.