Hello expert, I'm facing with a strange behaviour from Net::Telnet trying to get the command output from a Cisco device.
The result from "show run" command is placed into a scalar but printing the contents I get a number.
The dump log contests the right output.
Below the simple code that I'm using.

#/opt/ActivePerl-5.18/bin/perl use Net::Telnet; eval { $t = new Net::Telnet ( Timeout=>10, Errmode=> 'die', Prompt=> '/[# +>] $/' ); $t->open("x.x.x.x"); }; if($@) { print "error: " . $@ . "\n"; } else { print "success: " . $@ . "\n"; } $t->dump_log("file_dump"); $t->output_log("file_out"); #$t->max_buffer_length(50*1024*1024); $t->waitfor('/Username: ?$/i'); $t->print("*****"); $t->waitfor('/Password: ?$/i'); $t->print("*****"); $t->waitfor(-match=> '/> ?$/', -errmode=> "return") or die "login fail +ed: ", $t->lastline; $t->print("en"); $t->waitfor('/Password: ?$/i'); $t->print("*****"); $t->waitfor(-match=> '/# ?$/', -errmode=> "return") or die "login enab +le failed: ", $t->lastline; #$t->cmd(-string=> 'terminal pager 0', -timeout=> 30, -prompt=> '/# $/ +'); #$t->waitfor(-match=> '/# $/', -errmode=> "return") or die "prompt not + returned: ", $t->lastline; #@lines=$t->cmd(-string=> 'show run', -timeout=> 30, -prompt=> '/# $/' +); $t->print('terminal pager 0'); $t->waitfor('/# $/'); @showrun=$t->cmd('show run'); print @showrun . "\n"; print "moving to next statement\n";

running the script I get:

success:
2280
moving to next statement

Anyone can help me ?
Thanks

**************************************************************

I resolved, don't understand why but the command
print @showrun . "\n";
prints the numbers of element into the array.
The following code show the array contents:
print("@showrun\n");


In reply to Net::Telnet issue getting command output by gballanti

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.