If you use the option_log function to log the telnet options received and returned. You will see that Perl does not send the terminal type to the server by default. Server will default the terminal type to "network" for some reasons.
The right way to do this is to set the terminal type on the perl side.
my $termtype = 'vt100'; my $telopt_ttype_ok = '';
my $t = new Net::Telnet (Timeout => 5);
$t->option_callback(\&opt_callback);
$t->option_accept(Do=>Net::Telnet->TELOPT_TTYPE);
$t->suboption_callback(\&subopt_callback);
$t->open($server);
$t->input_log("runRemoteCommand_telnet.log");
$t->login($user, $pass);
$t->cmd($command);
exit 0;
sub opt_callback {
my ($obj, $option, $is_remote, $is_enabled, $was_enabled, $buf_position) = @_;
if ($option == Net::Telnet->TELOPT_TTYPE and $is_enabled and !$is_remote) {
$telopt_ttype_ok = 1;
}
1;
}
sub subopt_callback {
my ($obj, $option, $parameters) = @_;
my ($ors_old, $otm_old);
if ($option == Net::Telnet->TELOPT_TTYPE)
{
$ors_old = $obj->output_record_separator('');
$otm_old = $obj->telnetmode (0);
$obj->print("\xff\xfa", pack("CC", $option, 0), $termtype, "\xff\xf0");
$obj->output_record_separator($ors_old);
$obj->telnetmode ($otm_old);
}
1;
}
Refer to this