i'm having some trouble with Net::Telnet. the remote machine queries the TERM shell variable in order to
see if a 'resize' command should be issued. if TERM is
'no-resize-vt100', it does no resize, otherwise, 'resize'
is executed. of course, 'resize' hangs on a non-interactive
session, and the script gets no further. so, i try to
set TERM via $ENV{TERM}, but it doesn't seem to work.
in detail, here is the full script:
#!/usr/local/bin/perl
use Env qw(TERM);
$ENV{TERM} = 'no-resize-vt100';
use Net::Telnet;
$connection = new Net::Telnet ( Host=>'ssd.jpl.nasa.gov',
Port=>6775);
$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('500@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->waitfor('/.*Select.*: $/');
$connection->print('y');
$connection->print('q');
$connection->close;
exit 0;
which hangs at the $connection->open() command, because
the session tries to do a 'resize' (i can see this by
putting in a $connection->input_log(...) statement). so,
for some reason, the TERM variable doesn't seem to be
getting set/reset correctly. the equivalent expect script, which looks like this:
#!/usr/bin/expect
set env(TERM) no-resize-vt100
spawn telnet ssd.jpl.nasa.gov 6775
expect "Horizons> " { send "load vla-1\r" }
expect "Horizons> " { send page\r }
expect "Horizons> " { send 799\r }
expect -re ".*Select.*: $" { send e\r }
expect -re ".*Observe.*: $" { send o\r }
expect -re ".*Coordinate.*: $" { send 500@399\r }
expect -re ".*Starting.*: $" { send "1981-Mar-07 08:00\r" }
expect -re ".*Ending.*: $" { send "1981-Mar-07 17:00\r" }
expect -re ".*interval.*: $" { send 10m\r }
expect -re ".*Accept.*: $" { send y\r }
expect -re ".*Select.*: $" { send q\r }
exit 0
works perfectly, i.e., the TERM variable seems to get
set correctly, and the remote machine never attempts to
do the 'resize'.
what am i doing wrong in the Perl version?