I need help with Net:Telnet. Trying to connect to VT-100 terminal. When using normal telnet from console it works fine. I can connect and issue commands, but when i try the same from perl, it connects, but then nothing happens - i have no output or waitfor just timeouts or displays that prompt is not matched (but it its, beause its always three letters and > sign).
I'v tried all possible ways -> using methods like print, cmd, put, but without any success and stuck for 2 days on that thing.
Here is my sample code:
use Net::Telnet ();
my $conn = new Net::Telnet (TelnetMode => 0);
unless ($conn->open(Host => $host, Port => 23))
{
die "Error opening socket:: ".$conn->errmsg();
}
print "Connected to ".$conn->host().", port ".$conn->port()."\n";
$conn->prompt('/...>/'); # prompt is 014>
my $lines = $conn->put("15\r"); # command 15 to give me the site name
my ($a,$b);
($a,$b) = $conn->waitfor(Match=>'/...>/',Timeout=>100);
$conn->close;
When wrong command is entered, normally telnet displays error message and prompt, but from Perl it does nothing.
Input log is empty, output log is empty and dump log contains only following:
> 0x00000: 31 35 0d 0a 15..
I dont know what else to try.
Here is how looks normal telnet session output:
Trying xxx.xxx.xxx.xxx...
Connected to xxx.xxx.xxx.xxx.
Escape character is '^]'.
014>15
15
014 TMR Name
014>^]
telnet> quit
Connection closed.
Any help is appreciated
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.