I've got this problem where I can login, readline from a files in a directory and send them to a telnet terminal (HOSTA:5051). However, the output is being dumped on HOSTA:5005, which is non-interactive after logging in with user and password.
I can actually select from which port I dump the output, i.e. from 5001-5029. But since there is no interaction with the dummy-terminal, I cannot figure out how to actually get an extensive dump of the command result I am sending. Hence, I am unable to trap any errors caused by the commands I send.
Question is: whether the current Net::telnet module provide any thing to capture data from this sort of 'dummy telnet session'. I suspect it could be getline/get/buffer object. I am just no too sure how exactly either one of them works.
here's the current script I am using to capture output::
use Net::Telnet;
use POSIX qw(strftime);
my $lognamevar = strftime "%y-%m-%d", localtime;
my $dumpscreen_in = "dmpscrn-in-".$lognamevar.".txt";
my $dumpscreen_out= "dmpscrn-out-".$lognamevar.".txt";
my $dumpscreen_dump= "dmpscrn-dmp-".$lognamevar.".txt";
my $user = "root";
my $pass = "root";
open(DMPSCRNIN, ">>$dumpscreen_in") || die "Cannot open Dumpscreen tel
+net on port 5005 for error-trapping:$!\n";
open(DMPSCRNOUT, ">>$dumpscreen_out") || die "Cannot open Dumpscreen t
+elnet on port 5005 for error-trapping:$!\n";
$DMPSCRN_IN = *DMPSCRN_IN;
$DMPSCRN_OUT = *DMPSCRN_OUT;
$DMPSCRN_DMP = *DMPSCRN_DMP;
tlnDumpScreen;
sub tlnDumpScreen{
$dmpscreen = new Net::Telnet(
Timeout=>10,
Prompt=>'/.+>/',
Input_log => $DMPSCRN_IN,
Output_log => $DMPSCRN_OUT,
Dump_Log => $DMPSCRN_DMP,
Host => '192.168.6.40',
Port => '5005'
);
$dmpscreen->open();
$dmpscreen->waitfor('/name:/');
$dmpscreen->print($user);
$dmpscreen->waitfor('/password/i');
$dmpscreen->print($pass);
$dmpscreen->waitfor('/name:/');
$dmpscreen->print('getlinglines');
}
When I run this output, nothing is logged which is what I expect to be done when I run commands from the command terminal (HOSTA:5051).
I would appreciate if someone can give me a pointer on how to overcome this problem.
Thank you.
Thanks
p.s, i know the code looks messy. will clean up once i figure out this glitch.
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.