Hi,
This is my first Perl Script. I am trying to telnet to a cisco router and get the output from a command. I am running my script from a Windows XP machine from the command prompt.
I do not see the router output of the show command in the inputlog file. Please help.
My script is as follows.
#!C/Perl -w
use strict;
use warnings;
use Net::Telnet;
my $telnet = new Net::Telnet ( Timeout=>10, Binmode=> 1, telnetmode =>
+ 0, Input_log=>"input.log", Dump_log=>"dump.log", Output_log=>"output
+.log", Errmode=>'die', Prompt=>'/(?m:^[\w.-]+\s?(?:\(config[^\)]*\))?
+\s?[\$#>]\s?(?:\(enable\))?\s*$)/');
print "I am opening a connection\n";
$telnet->open('x.y.z.x');
print "i established a connection\n";
$telnet->waitfor('/Username: $/i');
$telnet->print('xxx');
print "i entered username\n";
$telnet->waitfor('/Password: $/i');
$telnet->print('yyy');
print "i entered password\n";
$telnet->waitfor('/.*$/i');
print $telnet->cmd('show platform');
print 'I am done executing the show command';
$telnet->close();
The input.log file does show me that it has connected to the router prompt and dump_log does have these lines at the end.
> 0x00000: 73 68 6f 77 20 70 6c 61 74 66 6f 72 6d 0a show platform.
< 0x00000: 0d 0a 56 50 4e 76 34 2d 31 6b 2d 52 52 30 33 23 ..VPNv4-1k-RR03#
But i dont see the output of the command "show platform" anywhere..
Please help.
TIA.
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.