this was the key. thanks much, fastolfe!
the solution by mr. muskrat was interesting, but really not the right way to go about this. thanks to him also though.
the reply by abigail is not right - Net::Telnet *does* correctly implement the telnet protocol, and establishes the connection in the proper way.
i was under the impression that the terminal type was always negotiated in a telnet session, but this is not the case. it turns out in my particular application, the remote client asks for the terminal type, but that particular negotiation is *not* enabled by default, so the local side was rejecting the request. i figured this out by doing a $connection->option_log('option.log'); statement (equivalently, i could have included the option in the object creation, but i like to keep them separate - makes it easier to comment them out as i go). so, i had to figure out how to make the local side not only accept a request for the terminal type, but then to send it back to the remote client. this is not trivial. fortunately, i found some help on the web at: http://dbforums.com/archive/96/2002/02/1/256002
which shows how to do it.
note that this takes advantage of a completely undocumented part of Net::Telnet (suboption_callback), and if i had not found this example on the web, i would have been pulling my hair out for days trying to figure it out. so, here is the modified code, which works perfectly:
#!/usr/local/bin/perl
use Net::Telnet qw (TELOPT_TTYPE);
$termtype = 'no-resize-vt100'; $telopt_ttype_ok = '';
$connection = new Net::Telnet ( Host=>'ssd.jpl.nasa.gov',
Port=>6775 );
$connection->option_callback(\&opt_callback);
$connection->option_accept(Do=>TELOPT_TTYPE);
$connection->suboption_callback(\&subopt_callback);
$connection->open();
$connection->waitfor('/Horizons> /');
$connection->print('load vla-1');
$connection->waitfor('/Horizons> /');
$connection->print('page');
$connection->waitfor('/Horizons> /');
$connection->print('799');
$connection->waitfor('/.*Select.*: $/');
$connection->print('e');
$connection->waitfor('/.*Observe.*: $/');
$connection->print('o');
$connection->waitfor('/.*Coordinate.*: $/');
$connection->print('-5@399');
$connection->waitfor('/.*Starting.*: $/');
$connection->print('1981-Mar-07 08:00');
$connection->waitfor('/.*Ending.*: $/');
$connection->print('1981-Mar-07 17:00');
$connection->waitfor('/.*interval.*: $/');
$connection->print('10m');
$connection->waitfor('/.*Accept.*: $/');
$connection->print('y');
$connection->input_log('horizons.ephem.log');
$connection->waitfor('/.*Select.*: $/');
$connection->input_log('');
$connection->print('q');
$connection->close;
exit 0;
sub opt_callback {
my ($obj, $option, $is_remote, $is_enabled, $was_enabled, $buf_positi
+on) = @_;
if ($option == TELOPT_TTYPE and $is_enabled and !$is_remote) {
$telopt_ttype_ok = 1; }
1;
}
sub subopt_callback {
my ($obj, $option, $parameters) = @_;
my $ors_old;
if ($option == TELOPT_TTYPE) {
$ors_old = $obj->output_record_separator("");
$obj->print("\xff\xfa", pack("CC", $option, 0), $termtype, "\xff\xf0
+");
$obj->output_record_separator($ors_old);
}
1;
}
thanks again to fastolfe for pointing me in the right direction!
bbutler
| [reply] [d/l] |