Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

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":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (4)
As of 2024-04-16 10:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found