Fix usage of telnet so that we do not keep sending useless newlines.

This commit is contained in:
Ben Greear
2020-03-10 17:18:04 -07:00
parent 2c3edf1820
commit b8c8f24f27

View File

@@ -35,7 +35,7 @@ sub new {
sub connect { sub connect {
my ($self, $host, $port) = @_; my ($self, $host, $port) = @_;
my $t = new Net::Telnet(Prompt => '/btbits>> $/', my $t = new Net::Telnet(Prompt => '/btbits>> $/',
Timeout => 2); Timeout => 10);
$self->{telnet} = \$t; $self->{telnet} = \$t;
$t->open(Host => $host, $t->open(Host => $host,
Port => $port, Port => $port,
@@ -104,16 +104,16 @@ sub doCmd {
sub doAsyncCmd { sub doAsyncCmd {
my $self = shift; my $self = shift;
my $cmd = shift; my $cmd = shift;
my $t = $self->telnet(); my $t = ${$self->{telnet}};
my @rv = (); my @rv = ();
if ( !$self->cli_send_silent() || (defined $ENV{'LOG_CLI'} && $ENV{'LOG_CLI'} ne "")) { if ( !$self->cli_send_silent() || (defined $ENV{'LOG_CLI'} && $ENV{'LOG_CLI'} ne "")) {
$self->log_cli($cmd); $self->log_cli($cmd);
} }
$t->print($cmd); $t->print($cmd);
my @rslt = $t->waitfor('/ \>\>RSLT:(.*)/'); #my @rslt = $t->waitfor('/ \>\>RSLT:(.*)/');
my @rslt2 = $t->waitfor( $self->async_waitfor() ); my @rslt2 = $t->waitfor( $self->async_waitfor() );
@rv = ( @rslt, @rslt2 ); @rv = ( @rslt2 );
if ( !$self->cli_rcv_silent() ) { if ( !$self->cli_rcv_silent() ) {
print "**************\n @rv \n................\n\n"; print "**************\n @rv \n................\n\n";