initself has asked for the wisdom of the Perl Monks concerning the following question:
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?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Managing TERM TYPE Option Requests with Net::Telnet
by castaway (Parson) on Aug 15, 2006 at 08:46 UTC | |
by initself (Monk) on Aug 16, 2006 at 02:31 UTC | |
by castaway (Parson) on Aug 16, 2006 at 08:19 UTC | |
|
Re: Managing TERM TYPE Option Requests with Net::Telnet
by Khen1950fx (Canon) on Aug 15, 2006 at 00:04 UTC |