Skip Menu |

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

Report information
The Basics
Id: 121397
Status: rejected
Worked: 15 min
Priority: 0/
Queue: Net-SSH2-Cisco

People
Owner: Nobody in particular
Requestors: Stefan.Novak [...] kabelplus.co.at
Cc:
AdminCc:

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



Subject: Bug in Net::SSH2::Cisco
Date: Wed, 26 Apr 2017 08:21:10 +0000
To: "'bug-Net-SSH2-Cisco [...] rt.cpan.org'" <bug-Net-SSH2-Cisco [...] rt.cpan.org>
From: "Novak Stefan (Kabelplus)" <Stefan.Novak [...] kabelplus.co.at>
Hello! I've just made a trivial script to get the output of show version: my $ssh = Net::SSH2::Cisco->new( host => $host, errmode => 'return', Timeout => $timeout, Binmode => 0); print "Use Net:SSH2:CISCO to connect.\n" if ($DEBUG == 1); if($ssh && $ssh->login($username, $password)){ $ssh->input_log("./ssh.log"); # Enable mode if ($ssh->enable($enable_password) ) { $ssh->cmd('terminal length 0'); @output = $ssh->cmd($cmd); #$ok = $ssh->print(@output); #print $ok; #for (@config) { # s/\\n// #} $return->{'type'} = "ssh2"; $return->{'output'} = \@output; return $return; } } On the output 2 chars at the beginning are missing: (fist line is correct, second one and following are wrong) Objects $VAR1 = { 'output' => [ ', 'Cisco IOS Software, C800 Software (C800-UNIVERSALK9-M), Version 15.5(3)M4a, RELEASE SOFTWARE (fc1) ' ',chnical Support: http://www.cisco.com/techsupport ' ',pyright (c) 1986-2016 by Cisco Systems, Inc. ' In the input_log is everything corret: enable Password: hostname#terminal length 0 hostname#show version Cisco IOS Software, C800 Software (C800-UNIVERSALK9-M), Version 15.5(3)M4a, RELEASE SOFTWARE (fc1) Technical Support: http://www.cisco.com/techsupport Copyright (c) 1986-2016 by Cisco Systems, Inc. Compiled Thu 06-Oct-16 14:23 by prod_rel_team Kind regards, Stefan
The script attached does not work. I made some assumptions, including that the output you were producing was generated with Data::Dumper. The issue you're seeing is related to how Data::Dumper displays output and has nothing to do with Net::SSH2::Cisco. See the following: ---- #!perl use strict; use warnings; use Net::SSH2::Cisco; use Data::Dumper; my $host = '192.168.100.1'; my $username = 'cisco'; my $password = 'cisco'; my $cmd = "show version"; my $ssh = Net::SSH2::Cisco->new( host => $host, input_log => 'ssh.log' ); my @output; if($ssh && $ssh->login($username, $password)){ @output = $ssh->cmd($cmd); } print $output[0]; print $output[1]; print $output[2]; print "----------\n"; print Dumper \@output; ---- When run, the output is as follows: ---- VinsWorldcom@C:\Users\VinsWorldcom\tmp> test.pl Cisco IOS Software, 7200 Software (C7200-ADVIPSERVICESK9-M), Version 12.4(24)T, RELEASE SOFTWARE (fc1) Technical Support: http://www.cisco.com/techsupport Copyright (c) 1986-2009 by Cisco Systems, Inc. ---------- $VAR1 = [ 'Cisco IOS Software, 7200 Software (C7200-ADVIPSERVICESK9-M), Version ',.4(24)T, RELEASE SOFTWARE (fc1) ' ',chnical Support: http://www.cisco.com/techsupport ' ',pyright (c) 1986-2009 by Cisco Systems, Inc. ' ---- Notice, @output (and hence the members of the array, $output[0], $output[1], $output[2] ...) has the correct values when printed alone - the first three output lines. When displayed with Data::Dumper, the carriage return / line feeds are not interpreted correctly with Data::Dumper causing the leading single quote and comma (',) to overwrite the first two characters of each subsequent data dumped line. If this is an issue, you can file a bug report with Data::Dumper. It would be helpful to include a dump log: my $ssh = Net::SSH2::Cisco->new( [...] dump_log => 'dump.log' ); when reporting as this will show the hex including 0d0a carriage return / line feeds.
Subject: AW: [rt.cpan.org #121397] Bug in Net::SSH2::Cisco
Date: Fri, 28 Apr 2017 07:29:16 +0000
To: "'bug-Net-SSH2-Cisco [...] rt.cpan.org'" <bug-Net-SSH2-Cisco [...] rt.cpan.org>
From: "Novak Stefan (Kabelplus)" <Stefan.Novak [...] kabelplus.co.at>
You are right! The problem is really the Data:Dumper Modules. Ticket can be closed.