Subject: | setting terminal height appropriately when requesting pty |
I haven't verified this in all versions of Net::SSH::Perl, but browsing the source of 1.30 and
previous versions, I see the same issue.
When requesting a pty, currently Net::SSH::Perl::SSH1.pm and SSH2.pm both set all terminal
sizes to 0. This is irritating when ssh'ing to a Cisco IOS device, as it uses the terminal height
parameter to set a default pager length.
The fix seems to be simple. I've attached a patch for SSH1.pm, it's a very similar fix for
SSH2.pm.
It would be awesome if this could be included in the next version.
Thanks
John
Subject: | fix-terminal-length.patch |
*** SSH1.pm.old Fri Apr 11 12:37:56 2008
--- SSH1.pm Fri Apr 11 12:32:20 2008
***************
*** 218,224 ****
$packet = $ssh->packet_start(SSH_CMSG_REQUEST_PTY);
my($term) = $ENV{TERM} =~ /(\w+)/;
$packet->put_str($term);
! $packet->put_int32(0) for 1..4;
$packet->put_int8(0);
$packet->send;
--- 218,233 ----
$packet = $ssh->packet_start(SSH_CMSG_REQUEST_PTY);
my($term) = $ENV{TERM} =~ /(\w+)/;
$packet->put_str($term);
! if (eval "require Term::ReadKey") {
! my @sz=Term::ReadKey::GetTerminalSize($ssh->sock);
! $packet->put_int32($sz[1]);
! $packet->put_int32($sz[0]);
! $packet->put_int32($sz[2]);
! $packet->put_int32($sz[3]);
! }
! else {
! $packet->put_int32(0) for 1..4;
! }
$packet->put_int8(0);
$packet->send;