I wrote an application that uses Net::Telnet to login to a remote server. On servers that don't expect to receive a particular term type, the application runs fine. However, on servers that expect a VT102 terminal type, the application errors out.

The logs for Putty tell me that the troublemaking server expects my application to send back a Terminal Type:

Event Log: server: SB TTYPE SEND Event Log: client: SB TTYPE IS XTERM

According to the docs, Net::Telnet the option_send method to answer a Telnet option negotiation request "is not yet implemented". Luckily I found Net::Telnet::Options, which appears to be designed to manage such requests.

use Net::Telnet; use Net::Telnet::Options; # Create Telnet Object my $t = new Net::Telnet(Dump_log => 't_dump.txt', Output_log => 't_input.txt', Input_log => 't_output.txt', Errmode => 'return', Timeout => '10', ); # Create Telnet Options Object my $nto = Net::Telnet::Options->new(); # Accept and deal with incoming TERM TYPE option requests $nto->acceptDoOption('TTYPE', {'SB' => \&ttype_sb_callback } ); sub ttype_sb_callback { my ($cmd, $subcmd, $data, $pos) = @_; my $socket = "23"; $nto->sendOpt($socket, 'SB', 24, 'IS', 'VT102'); return ; } $t->open($host); $t->waitfor('/login:/'); $t->print("$username");

Right after the initial login, the error occurs since the TERM TYPE handshake is not able to be made between my application and the server application:

($prematch, $match) = $t->waitfor(Match => "/Welcome/"); unless (defined $match) { print $t->errmsg; }

The error message is: pattern match read eof

Net::Telnet::Options looks very promising but it looks like I'm not integrating it into my code correctly. What might I have to change to get the application to see my TERM TYPE response?


In reply to Managing TERM TYPE Option Requests with Net::Telnet by initself

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.