Skip Menu |

This queue is for tickets about the Net-SSH2-Cisco CPAN distribution.

Report information
The Basics
Id: 122919
Status: resolved
Worked: 6 hours (360 min)
Priority: 0/
Queue: Net-SSH2-Cisco

People
Owner: VINSWORLD [...] cpan.org
Requestors: eric [...] amerca.nl
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: 0.04



Subject: Bug/improvement Net::SSH2::Cisco
Date: Tue, 29 Aug 2017 07:32:14 +0200
To: bug-Net-SSH2-Cisco [...] rt.cpan.org
From: Eric Smid <eric [...] amerca.nl>
Hi Michael, First I want to thank you for the great work for the Net::SSH2::Cisco module. When using this module I found that the output of the cmd sub differed from the output of the cmd sub of the Net::Telnet::Cisco module. I ran into two problems: The cmd sub of Net::Telnet::Cisco returns \n at the end of the line, while the same devices return \r\n at the and of the line when using Net::SSH2::Cisco. I solved this by adding the red lines below, which my ($lines, $last_prompt); { local $self->{errormode} = "return"; #send $self->put($string . $ors); #wait select(undef,undef,undef,$pause); # sleep #read ($lines, $last_prompt) = $self->waitfor($prompt); } # Added by Eric Smid to make output the same as Net::Telnet::Cisco if ( defined $lines) { $lines =~ s/\r\n/\n/mg; # Replace \r\n by \n } return $self->error("command timed-out") if $self->timed_out; return $self->error($self->errmsg) if $self->errmsg ne ""; The second issue is that the normalize sub puts the \n character at the end of the line at the beginning of the next line. This is also an issue with Net::Telnet::Cisco. I didn't see this behaviour earlier with Net::Telnet::Cisco, because I normally set terminal length to 0. With Net::Telnet:Cisco _normalize is only executed when there is a "more: prompt. In Net::SSH2:Cisco it is always executed. So: Line 1\n Line 2\n Changes to Line 1 \n Line 2 \n I replaced _normalize with this sub. I also use HEX character matching to make the code more readable. # Changed by Eric Smid. This Solves the problem where \n is at the beginning of the next line instead of # at the end of the current line. sub _normalize { foreach (@_) { 1 while s/[^\x08\x7F][\x08\x7F]//g; # Remove combination of non BS or DEL character followed by BS or DEL character, check again after removal s/^.*[\x15]//g; # Remove all characters before and including NAK character } return wantarray ? @_ : join "", @_; # ORS instead? } Is it possible to add these improvements to your code at CPAN? Best Regards, Eric Smid
I think I have a fix. The _normalize routine does always run - you're right - and it shouldn't. The cmd() architecture of N::T::C and N::S::C are a bit different due to the underlying modules, Net::Telnet and Net::SSH2 respectively. The solution is to move _normalize() to when I do the autopaging - similar as in N::T::C. I do that in waitfor(). Also, not sure where / how Net::Telnet / Net::Telnet::Cisco clips the \015\012 to just \012, but it does indeed somewhere. The actual return from the router if you use dump log is \015\012 so Net::SSH2::Cisco reports it correctly, but to keep consistent with Net::Telnet::Cisco, I've added a fix. Note, the "\nLine1" issue is a Net::Telnet::Cisco "bug". I believe it's fixed now in Net::Telnet::Cisco, but output after the first autopage will be different between the two now; N::T::C doing: Line1\n Line2\n up to the first autopage, then switching to: \nLine5 \nLine5 ... Net::SSH2::Cisco will always use "Line1\n". If you please, patch your version with this and let me know if it suits you.
Subject: Cisco.pm.patch
--- lib\Net\SSH2\Cisco.pm 2016-10-13 14:28:44.000000000 -0400 +++ lib\Net\SSH2\Cisco.pm 2017-08-29 18:53:01.757873100 -0400 @@ -29,7 +29,7 @@ use strict; use warnings; -our $VERSION = '0.03'; +our $VERSION = '0.04'; our @ISA; use version; @@ -309,7 +309,10 @@ select(undef,undef,undef,$pause); # sleep #read - ($lines, $last_prompt) = $self->waitfor($prompt); + ($lines, $last_prompt) = $self->waitfor( + match => $prompt, + normalize_cmd => $normal + ); } return $self->error("command timed-out") if $self->timed_out; @@ -326,6 +329,13 @@ push @$output, substr($lines, $firstpos) } + # behave like Net::Telnet(::Cisco) CRLF + if (!$self->{bin_mode}) { + for (0..$#$output) { + $output->[$_] =~ s/\015\012$/\012/; + } + } + # clean up if ($rm eq "auto") { if ((defined @$output[0]) and (@$output[0] =~ /^$string(?:\r)?(?:\n)?/)) { @@ -372,10 +382,6 @@ } } - if ($normal) { - @$output = _normalize (@$output); - } - ## Return command output via named arg, if requested. if (defined $output_ref) { if (ref($output_ref) eq "SCALAR") { @@ -1018,6 +1024,11 @@ &_log_print($self->{outputlog}, $buf); } + ## Convert native newlines to CR LF. +# if (!$self->{bin_mode}) { +# $buf =~ s(\n)(\015\012)g; +# } + &_put($self, \$buf, "print"); } @@ -1075,6 +1086,11 @@ &_log_print($self->{outputlog}, $buf); } + ## Convert native newlines to CR LF. +# if (!$self->{bin_mode}) { +# $buf =~ s(\n)(\015\012)g; +# } + &_put($self, \$buf, "put"); } @@ -1126,6 +1142,7 @@ my $chan = $self->{_SSH_CHAN_}; my $clear = $self->{waitfor_clear}; my $cmd = $self->{last_cmd}; + my $normal = $self->{normalize_cmd}; my $rm = $self->{cmd_rm_mode}; my $timeout = $self->{time_out}; @@ -1160,6 +1177,8 @@ $errmode = &_parse_errmode($self, $arg); } elsif (/^-?match$/i) { push @matches, _prep_regex($arg) + } elsif (/^-?normalize_cmd$/i) { + $normal = $arg } elsif (/^-?string$/i) { $arg =~ s/'/\\'/g; # quote ticks push @matches, $arg @@ -1214,9 +1233,17 @@ } } # autopage - if ($ap and ($buf =~ /($MORE)/)) { - #$buf =~ s/$MORE//g; - $self->put(" "); + if ($ap) { + if ($buf =~ /($MORE)/) { + $self->put(" "); + } + if ($normal) { + $buf =~ s/$MORE\s*//g; +# $buf = _normalize($buf); + $buf =~ s/\s*\010.*\010\s*//g; + $buf =~ s/\177//g; + $buf =~ s/^.*\025//mg; + } } $buffer .= $buf }
Subject: Re: [rt.cpan.org #122919] Bug/improvement Net::SSH2::Cisco
Date: Wed, 30 Aug 2017 21:30:11 +0200
To: bug-Net-SSH2-Cisco [...] rt.cpan.org
From: Eric Smid <eric [...] amerca.nl>
Hi Michael, Tnx for your quick response! I did some tests. But stille had some issues. I already have a solution, and will let you know tomorrow. I'm wondering why you added a test for binmode to the replacement pf CRLF by LF. If I understand correctly, binmode is only used for the login procedure. I couldn't find waitfor is used for the login procedure. Shouldn't it be better to add te replacement of CRLF by LF to sub waitfor? Regards, Eric On 30-8-2017 01:08, Michael Vincent via RT wrote: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=122919 > > > I think I have a fix. The _normalize routine does always run - you're right - and it shouldn't. The cmd() architecture of N::T::C and N::S::C are a bit different due to the underlying modules, Net::Telnet and Net::SSH2 respectively. The solution is to move _normalize() to when I do the autopaging - similar as in N::T::C. I do that in waitfor(). > > Also, not sure where / how Net::Telnet / Net::Telnet::Cisco clips the \015\012 to just \012, but it does indeed somewhere. The actual return from the router if you use dump log is \015\012 so Net::SSH2::Cisco reports it correctly, but to keep consistent with Net::Telnet::Cisco, I've added a fix. > > Note, the "\nLine1" issue is a Net::Telnet::Cisco "bug". I believe it's fixed now in Net::Telnet::Cisco, but output after the first autopage will be different between the two now; N::T::C doing: > > Line1\n > Line2\n > up to the first autopage, then switching to: > \nLine5 > \nLine5 > ... > > Net::SSH2::Cisco will always use "Line1\n". > > If you please, patch your version with this and let me know if it suits you. > >
Subject: Re: [rt.cpan.org #122919] Bug/improvement Net::SSH2::Cisco
Date: Thu, 31 Aug 2017 07:58:15 +0200
To: bug-Net-SSH2-Cisco [...] rt.cpan.org
From: Eric Smid <eric [...] amerca.nl>
Hi Michael, Attached you can find my patch from your version 0v4 to my version 0v41. The replacement of the substitutions in sub _normalize by the substitutions for $buf in sub waitfor are not correct. The new substitutions cause whitespace for the first line after -- More -- to disappear. After a character is send to the device the device returns backspaces to remove the more prompt. Example: $buf with more: "Serial1/0:10\r\n --More-- " $buf after the character is send: "\b\b\b\b\b\b\b\b\b \b\b\b\b\b\b\b\b\b description To" When doing the normalize for $buffer instead of $buf, the whole output is in one string. By running the sub _normalize for $buffer, the output is correct. The old _normalize produces the same output for strings, which applies to $buffer. To let sub _normalize also produce the correct output for arrays, i changed _normalize. I'll also contact the Net::Telnet::Cisco develloper to change the _normalize routine the same way. I moved the substitution of CRLF to LF to sub waitfor. And removed the check for binmode, because i think binmode is not used at all in sub waitfor. Regards, Eric On 2017-08-30 21:30, Eric Smid wrote: Show quoted text
> Hi Michael, > > Tnx for your quick response! > > I did some tests. But stille had some issues. > I already have a solution, and will let you know tomorrow. > > I'm wondering why you added a test for binmode to the replacement pf > CRLF by LF. > If I understand correctly, binmode is only used for the login > procedure. I couldn't find waitfor is used for the login procedure. > > Shouldn't it be better to add te replacement of CRLF by LF to sub > waitfor? > > Regards, > > Eric > > > On 30-8-2017 01:08, Michael Vincent via RT wrote:
>> <URL: https://rt.cpan.org/Ticket/Display.html?id=122919 > >> >> I think I have a fix. The _normalize routine does always run - you're >> right - and it shouldn't. The cmd() architecture of N::T::C and >> N::S::C are a bit different due to the underlying modules, Net::Telnet >> and Net::SSH2 respectively. The solution is to move _normalize() to >> when I do the autopaging - similar as in N::T::C. I do that in >> waitfor(). >> >> Also, not sure where / how Net::Telnet / Net::Telnet::Cisco clips the >> \015\012 to just \012, but it does indeed somewhere. The actual >> return from the router if you use dump log is \015\012 so >> Net::SSH2::Cisco reports it correctly, but to keep consistent with >> Net::Telnet::Cisco, I've added a fix. >> >> Note, the "\nLine1" issue is a Net::Telnet::Cisco "bug". I believe >> it's fixed now in Net::Telnet::Cisco, but output after the first >> autopage will be different between the two now; N::T::C doing: >> >> Line1\n >> Line2\n >> up to the first autopage, then switching to: >> \nLine5 >> \nLine5 >> ... >> >> Net::SSH2::Cisco will always use "Line1\n". >> >> If you please, patch your version with this and let me know if it >> suits you. >> >>

Message body is not shown because sender requested not to inline it.

Eric, Thanks for you help on this. As you can imagine, blending 2 modules (Net::Telnet::Cisco with Net::SSH2) while using the API from yet a third (Net::Telnet to keep consistent) comes with its own set of challenges. 1) "The new substitutions cause whitespace for the first line after -- More-- to disappear." Yes, you're correct, I noticed that last night too. I had a fix, but yours is more elegant; running on $buffer once all output is collected versus on each fill of $buf. 2) "The old _normalize produces the same output for strings, which applies to $buffer. To let sub _normalize also produce the correct output for arrays, i changed _normalize." Not sure this is needed. We pass in a string ($buffer). The original _normalize() converts it to a string with the join(), which I think we can both agree is a bit redundant / useless, but nonetheless. I'm trying to keep consistency between the subs I "borrow" from Net::Telnet and Net::Telnet::Cisco. The only change I made to _normalize() is to remove the g-modifier in the return() as it generates a warning ("Use of /g modifier is meaningless in split") - note, Net::Telnet::Cisco does not 'use warnings' so you don't see it there. For me, with the other changes, original _normalize() works so I keep it. Keeping with the logic flow from Net::Telnet::Cisco, _normalize should only run it autopage() is enabled so I have that as an if() condition along with checking the $normal variable. 3) "I moved the substitution of CRLF to LF to sub waitfor." Yes, I agree that's where it should be. Again, to keep as consistent as possible with Net::Telnet and Net::Telnet::Cisco, I use the _interpret_cr() sub and add it into the module. This relates to -binmode. I mistakenly ported my use of binmode from another module to this one. Enabling binmode on the SSH channel doesn't seem to have an effect. Reading the perldoc for Net::Telnet (on which Net::Telnet::Cisco is based), binmode controls the CR LF translations. It's enabled by default. I removed the binmode setting on the SSH Channel from login() - it has no effect. Looking at the logic from Net::Telnet, CR LF translations are done on the input channel (from the device to our computer) only if !binmode (it's counter-intuitive to me, but that's how it's done). I emulate that behavior by enclosing my translation in a logical if() test for binmode. Note Net::Telnet also does translation on the output channel (from our computer to the device), but this breaks SSH2 (at least for me), so the translation routines are in print() and put(), but commented out. I also updated the POD for binmode to reflect the same as Net::Telnet, excluding the output channel translation. -- I also took some time to fix a small bug in enable() and change put() to print() to be more consistent with Net::Telnet::Cisco behavior. TESTING ALL OF THIS: Attached, you'll find my test programs along with version 0.04_2 of the module (rather than a patch). Probably should have used better versioning, as the update we agree on will be on CPAN as 0.04, but anyway ... I created some scripts to cycle through all combinations of autopage, binmode and normalize_cmd and ran the tests on both Windows 10 x64 / Strawberry Perl 5.24.1 MSWin32-x64-multi-thread and Ubuntu 16.04 64-bit / Perl 5.22.1 x86_64-linux-gnu-thread-multi. Note: On Windows, you'll need xxd.exe and diff.exe. I'm running against Cisco ISR4351 with IOS XE 16.03.03. Structure: compare.pl dotest.bat dotest.sh Net-SSH2-Cisco-0.04/ From Net-SSH2-Cisco-0.04/: (Windows) ../dotest.bat (Linux) bash ../dotest.sh I got no differences (good) on any combination on either Windows or Linux platforms. Note, you may see a diff on the 'show version' output on the system uptime line depending on how the test runs fall; example: [...] diffs (AP=0 BM=1 NC=1): 67c67 < 0000420: 732c 2031 3820 6d69 6e75 7465 730d 0d0a s, 18 minutes... --- Show quoted text
> 0000420: 732c 2031 3920 6d69 6e75 7465 730d 0d0a s, 19 minutes...
[...] This can be safely ignored. Please give this Cisco.pm a test in your environment and let me know results. Thanks again!
Subject: Cisco.pm

Message body is not shown because it is too large.

Subject: compare.pl
#!perl use strict; use warnings; my $HOST = '1.1.1.1'; my $USER = 'cisco'; my $PASS = 'cisco'; my $ENPS = $PASS; my $TYPE = $ARGV[0]; my $AP = $ARGV[1]; my $BM = $ARGV[2]; my $NC = $ARGV[3]; use Net::SSH2::Cisco; use Net::Telnet::Cisco; my $c = ('Net::' . $TYPE . '::Cisco')->new( host => $HOST, dump_log => 'dump-' . $TYPE . '.txt', input_log => 'in-' . $TYPE . '.txt', output_log => 'out-' . $TYPE . '.txt', ); $c->login($USER, $PASS); $c->autopage($AP); $c->binmode($BM); $c->normalize_cmd($NC); my (@out, $fh); if (!$AP) { $c->cmd('term len 0'); } @out = $c->cmd('show version'); open $fh, ">", $TYPE . "-ver.log"; for (@out) { print $fh $_; } @out = $c->cmd('disable'); @out = $c->enable($ENPS); @out = $c->cmd('show run'); open $fh, ">", $TYPE . "-run.log"; for (@out) { print $fh $_; } close $fh; $c->close; system("xxd $TYPE-run.log $TYPE-run.log.xxd"); system("xxd $TYPE-ver.log $TYPE-ver.log.xxd");
Subject: dotest.bat
Download dotest.bat
application/octet-stream 338b

Message body not shown because it is not plain text.

Subject: dotest.sh
Download dotest.sh
application/octet-stream 317b

Message body not shown because it is not plain text.

Subject: Re: [rt.cpan.org #122919] Bug/improvement Net::SSH2::Cisco
Date: Thu, 31 Aug 2017 17:05:07 +0200
To: bug-Net-SSH2-Cisco [...] rt.cpan.org
From: Eric Smid <eric [...] amerca.nl>
Hi Vincent, Thanks for your explanation. I'll do some tests next week. I'll let you know the results. For your information I'm using the module on a Solaris system and query different Cisco devices. For some reason I have trouble with commands that time-out at Cisco SG300 devices. Login seems to work, but when I send a command I get no response and session times out. I'm not sure if the command is received at the SG300. Not important for my current project, but if possible I want to solve this too. Regards, Eric On 31-8-2017 16:33, Michael Vincent via RT wrote: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=122919 > > > Eric, > > Thanks for you help on this. As you can imagine, blending 2 modules (Net::Telnet::Cisco with Net::SSH2) while using the API from yet a third (Net::Telnet to keep consistent) comes with its own set of challenges. > > 1) > "The new substitutions cause whitespace for the first line after -- More-- to disappear." > > Yes, you're correct, I noticed that last night too. I had a fix, but yours is more elegant; running on $buffer once all output is collected versus on each fill of $buf. > > 2) > "The old _normalize produces the same output for strings, which applies to $buffer. > To let sub _normalize also produce the correct output for arrays, i changed _normalize." > > Not sure this is needed. We pass in a string ($buffer). The original _normalize() converts it to a string with the join(), which I think we can both agree is a bit redundant / useless, but nonetheless. I'm trying to keep consistency between the subs I "borrow" from Net::Telnet and Net::Telnet::Cisco. The only change I made to _normalize() is to remove the g-modifier in the return() as it generates a warning ("Use of /g modifier is meaningless in split") - note, Net::Telnet::Cisco does not 'use warnings' so you don't see it there. For me, with the other changes, original _normalize() works so I keep it. > > Keeping with the logic flow from Net::Telnet::Cisco, _normalize should only run it autopage() is enabled so I have that as an if() condition along with checking the $normal variable. > > > 3) > "I moved the substitution of CRLF to LF to sub waitfor." > > Yes, I agree that's where it should be. Again, to keep as consistent as possible with Net::Telnet and Net::Telnet::Cisco, I use the _interpret_cr() sub and add it into the module. This relates to -binmode. > > I mistakenly ported my use of binmode from another module to this one. Enabling binmode on the SSH channel doesn't seem to have an effect. Reading the perldoc for Net::Telnet (on which Net::Telnet::Cisco is based), binmode controls the CR LF translations. It's enabled by default. > > I removed the binmode setting on the SSH Channel from login() - it has no effect. Looking at the logic from Net::Telnet, CR LF translations are done on the input channel (from the device to our computer) only if !binmode (it's counter-intuitive to me, but that's how it's done). I emulate that behavior by enclosing my translation in a logical if() test for binmode. > > Note Net::Telnet also does translation on the output channel (from our computer to the device), but this breaks SSH2 (at least for me), so the translation routines are in print() and put(), but commented out. I also updated the POD for binmode to reflect the same as Net::Telnet, excluding the output channel translation. > > -- > > I also took some time to fix a small bug in enable() and change put() to print() to be more consistent with Net::Telnet::Cisco behavior. > > TESTING ALL OF THIS: > Attached, you'll find my test programs along with version 0.04_2 of the module (rather than a patch). Probably should have used better versioning, as the update we agree on will be on CPAN as 0.04, but anyway ... > > I created some scripts to cycle through all combinations of autopage, binmode and normalize_cmd and ran the tests on both Windows 10 x64 / Strawberry Perl 5.24.1 MSWin32-x64-multi-thread and Ubuntu 16.04 64-bit / Perl 5.22.1 x86_64-linux-gnu-thread-multi. > > Note: On Windows, you'll need xxd.exe and diff.exe. > > I'm running against Cisco ISR4351 with IOS XE 16.03.03. > > Structure: > compare.pl > dotest.bat > dotest.sh > Net-SSH2-Cisco-0.04/ > > From Net-SSH2-Cisco-0.04/: > > (Windows) > ../dotest.bat > > (Linux) > bash ../dotest.sh > > I got no differences (good) on any combination on either Windows or Linux platforms. Note, you may see a diff on the 'show version' output on the system uptime line depending on how the test runs fall; example: > > [...] > diffs (AP=0 BM=1 NC=1): > 67c67 > < 0000420: 732c 2031 3820 6d69 6e75 7465 730d 0d0a s, 18 minutes... > ---
>> 0000420: 732c 2031 3920 6d69 6e75 7465 730d 0d0a s, 19 minutes...
> [...] > > This can be safely ignored. > > Please give this Cisco.pm a test in your environment and let me know results. > > Thanks again! > >
Subject: Re: [rt.cpan.org #122919] Bug/improvement Net::SSH2::Cisco
Date: Thu, 31 Aug 2017 17:07:39 +0200
To: bug-Net-SSH2-Cisco [...] rt.cpan.org
From: Eric Smid <eric [...] amerca.nl>
By the way, regarding the normalize bug: https://rt.cpan.org/Public/Bug/Display.html?id=118170 On 31-8-2017 17:05, Eric Smid wrote: Show quoted text
> Hi Vincent, > > Thanks for your explanation. > I'll do some tests next week. > I'll let you know the results. > > For your information I'm using the module on a Solaris system and > query different Cisco devices. > For some reason I have trouble with commands that time-out at Cisco > SG300 devices. > Login seems to work, but when I send a command I get no response and > session times out. > I'm not sure if the command is received at the SG300. > > Not important for my current project, but if possible I want to solve > this too. > > Regards, > > Eric > > > On 31-8-2017 16:33, Michael Vincent via RT wrote:
>> <URL: https://rt.cpan.org/Ticket/Display.html?id=122919 > >> >> Eric, >> >> Thanks for you help on this.  As you can imagine, blending 2 modules >> (Net::Telnet::Cisco with Net::SSH2) while using the API from yet a >> third (Net::Telnet to keep consistent) comes with its own set of >> challenges. >> >> 1) >> "The new substitutions cause whitespace for the first line after -- >> More-- to disappear." >> >> Yes, you're correct, I noticed that last night too.  I had a fix, but >> yours is more elegant; running on $buffer once all output is >> collected versus on each fill of $buf. >> >> 2) >> "The old _normalize produces the same output for strings, which >> applies to $buffer. >>   To let sub _normalize also produce the correct output for arrays, i >> changed _normalize." >> >> Not sure this is needed.  We pass in a string ($buffer).  The >> original _normalize() converts it to a string with the join(), which >> I think we can both agree is a bit redundant / useless, but >> nonetheless.  I'm trying to keep consistency between the subs I >> "borrow" from Net::Telnet and Net::Telnet::Cisco.  The only change I >> made to _normalize() is to remove the g-modifier in the return() as >> it generates a warning ("Use of /g modifier is meaningless in split") >> - note, Net::Telnet::Cisco does not 'use warnings' so you don't see >> it there.  For me, with the other changes, original _normalize() >> works so I keep it. >> >> Keeping with the logic flow from Net::Telnet::Cisco, _normalize >> should only run it autopage() is enabled so I have that as an if() >> condition along with checking the $normal variable. >> >> >> 3) >> "I moved the substitution of CRLF to LF to sub waitfor." >> >> Yes, I agree that's where it should be.  Again, to keep as consistent >> as possible with Net::Telnet and Net::Telnet::Cisco, I use the >> _interpret_cr() sub and add it into the module.  This relates to >> -binmode. >> >> I mistakenly ported my use of binmode from another module to this >> one.  Enabling binmode on the SSH channel doesn't seem to have an >> effect.  Reading the perldoc for Net::Telnet (on which >> Net::Telnet::Cisco is based), binmode controls the CR LF >> translations.  It's enabled by default. >> >> I removed the binmode setting on the SSH Channel from login() - it >> has no effect.  Looking at the logic from Net::Telnet, CR LF >> translations are done on the input channel (from the device to our >> computer) only if !binmode (it's counter-intuitive to me, but that's >> how it's done).  I emulate that behavior by enclosing my translation >> in a logical if() test for binmode. >> >> Note Net::Telnet also does translation on the output channel (from >> our computer to the device), but this breaks SSH2 (at least for me), >> so the translation routines are in print() and put(), but commented >> out.  I also updated the POD for binmode to reflect the same as >> Net::Telnet, excluding the output channel translation. >> >> -- >> >> I also took some time to fix a small bug in enable() and change put() >> to print() to be more consistent with Net::Telnet::Cisco behavior. >> >> TESTING ALL OF THIS: >> Attached, you'll find my test programs along with version 0.04_2 of >> the module (rather than a patch).  Probably should have used better >> versioning, as the update we agree on will be on CPAN as 0.04, but >> anyway ... >> >> I created some scripts to cycle through all combinations of autopage, >> binmode and normalize_cmd and ran the tests on both Windows 10 x64 / >> Strawberry Perl 5.24.1 MSWin32-x64-multi-thread and Ubuntu 16.04 >> 64-bit / Perl 5.22.1 x86_64-linux-gnu-thread-multi. >> >> Note:  On Windows, you'll need xxd.exe and diff.exe. >> >> I'm running against Cisco ISR4351 with IOS XE 16.03.03. >> >> Structure: >> compare.pl >> dotest.bat >> dotest.sh >> Net-SSH2-Cisco-0.04/ >> >>  From Net-SSH2-Cisco-0.04/: >> >> (Windows) >> ../dotest.bat >> >> (Linux) >> bash ../dotest.sh >> >> I got no differences (good) on any combination on either Windows or >> Linux platforms.  Note, you may see a diff on the 'show version' >> output on the system uptime line depending on how the test runs fall; >> example: >> >> [...] >> diffs (AP=0 BM=1 NC=1): >> 67c67 >> < 0000420: 732c 2031 3820 6d69 6e75 7465 730d 0d0a  s, 18 minutes... >> ---
>>> 0000420: 732c 2031 3920 6d69 6e75 7465 730d 0d0a  s, 19 minutes...
>> [...] >> >> This can be safely ignored. >> >> Please give this Cisco.pm a test in your environment and let me know >> results. >> >> Thanks again! >> >>
>
On Thu Aug 31 11:07:53 2017, eric@amerca.nl wrote: Show quoted text
> By the way, regarding the normalize bug: > > https://rt.cpan.org/Public/Bug/Display.html?id=118170 > >
I looked at that and applied the fix in a test version of Net::SSH2::Cisco - it also works for me. So if Net::Telnet::Cisco ever fixes the bug (note some tickets in that queue are *very* old) I can apply the same fix to Net::SSH2::Cisco and it should still work. Note that the current version of _normalize() in Net::SSH2::Cisco copied from Net::Telnet::Cisco fixes the g-modifier and seems to work fine for me. The Net::Telnet::Cisco bug may stem from the way it handles autopaging, using: ...SUPER::cmd(String => " " ... instead of just: ...put(' ') ... like I do in Net::SSH2::Cisco since I'm blending a few modules and put my autopaging in waitfor(). For the SG300 issue, try enabling dump_log: my $session = Net::SSH2::Cisco->new( host => 'sg300.domaind.com', dump_log => 'sg300-dump.log', );
Updated version 0.04 published to CPAN.