Skip to content

Commit 128cd72

Browse files
committed
remove _stty_rows, add connection_method
This removes _stty_rows. It was an experiment that I never got to work. The idea was that we could tell a device that we were a 3000 line long terminal and defeat the devices "More" prompt, but no device that I found would accept such a thing. Most devices have a hard coded screen size of xxx lines which shows a more prompt even if it thinks the physical screen is bigger. For the "connection_method" I decided I wanted a better way to determine the hostname or IP of the device I connect to when parsing script output. Usually I look for the line "Adding this thing to known hosts.." or whatever, but that doesn't work if the device is already in known hosts, or you use telnet, or any number of other things. So now if you turn on --debug it will show a connection string.
1 parent 36ff282 commit 128cd72

File tree

1 file changed

+8
-13
lines changed

1 file changed

+8
-13
lines changed

lib/App/Tel.pm

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ sub new {
8383
my $self = {
8484
'stdin' => Expect->exp_init(\*STDIN),
8585
'connected' => CONN_OFFLINE,
86+
'current_method'=> undef,
8687
'enabled' => 0,
8788
'title_stack' => 0,
8889
'log_stdout' => 1,
@@ -418,18 +419,6 @@ sub profile {
418419
return $profile;
419420
}
420421

421-
# I don't think I've ever seen this work. Should probably remove it
422-
sub _stty_rows {
423-
my $new_rows = shift;
424-
eval {
425-
Module::Load::load Term::ReadKey;
426-
my ($columns, undef, $xpix, $ypix) = GetTerminalSize(\*STDOUT);
427-
SetTerminalSize($columns, $new_rows, $xpix, $ypix, \*STDOUT);
428-
};
429-
430-
warn $@ if ($@);
431-
}
432-
433422
=head2 session
434423
435424
my $session = $self->session;
@@ -635,6 +624,7 @@ sub login {
635624
my $hostsearched = 0;
636625

637626
METHOD: for (@{$self->methods}) {
627+
$self->{'current_method'} = $_;
638628
# this dies if the method is not found.
639629
$self->connect($self->method_options($_, $hostname));
640630

@@ -691,7 +681,12 @@ sub login {
691681
);
692682
}
693683

694-
warn "Connection to $hostname failed.\n" if !$self->connected;
684+
if (!$self->connected) {
685+
warn "Connection to $hostname failed.\n";
686+
} else {
687+
warn "\nConnected to $hostname via $self->{'current_method'}\n" if $self->{'debug'};
688+
}
689+
695690
return $self;
696691
}
697692

0 commit comments

Comments
 (0)