merkata has asked for the wisdom of the Perl Monks concerning the following question:

Hi guys, I have a strange problem:
I'm trying to connect to a Cisco box via ssh to execute some 'show' commands on a regular basis and later process them for some comparison.However, I cannot even connect to the box.This is the code:

------------------------begin code
#!/usr/bin/perl -w
use Net::SSH::Perl;
my $ssh = Net::SSH::Perl->new("cisco");
print "Trying to get in...\n";
my $stat = $ssh->login("user",'pass');
print "Status is $stat\n";
my($values, $stderr, $exit) = $ssh->cmd('show proc cpu');
print "$values";

-----------------------end code

pretty simple and should do the trick, but it doesn't. The output I get is:

Trying to get in...
Status is 44
Use of uninitialized value $values in string at ./get_itp_stats.pl line 10.

Can someone see trough in this?

Thanks

Replies are listed 'Best First'.
Re: Net::SSH::Perl returns status 44
by lamp (Chaplain) on Sep 25, 2008 at 07:04 UTC
    The message which you are getting is a warning. Check for the value of '$values' before printing. For debugging the issue, use 'debug' option of 'Net::SSH::Perl' module.
    my $ssh = Net::SSH::Perl->new("cisco", debug => 1);
      I'm a bad person for not using debug...thanks lamp.

      The debug pointed something out, that was later clarified by this thread -> http://www.cpanforum.com/threads/851.
      It appears that Cisco have some buggy implementation of SSH2 that would not allow multiple channels, so Net::SSH::Perl fails at opening a second dummy channel.After making some changes in SSH2.pm (explained in the thread above) to cope with Cisco, it connects just fine.

      Thanks again!