Mazinator
Mazinator

Reputation: 34

Perl SSH Script unable to load math library?

I am trying to run a Perl script that takes user, pass, ip arguments and uses that to check the version of a network switch through ssh. However when i run it on our server i keep getting:

Math::BigInt: couldn't load specified math lib(s), fallback to Math::BigInt::FastCalc at /usr/lib/perl5/site_perl/5.10.0/Crypt/DH.pm line 6

It the proceeds to hang for a bit then return with no output. What is causing this to fail and how can i get around it? I do not have access to install extra modules to the server.


EDIT: I have checked the currently installed modules and Net::SSH:Perl, Math::BigInt::FastCalc, and Math::Pari are all installed, so i have no idea why it is having problems loading those modules.


Here is my script for reference:

#!/usr/bin/perl


# Outputs the name of the Flash File (which denotes the software version) of the switch
#Input: User Pass Host

open(FH, ">>unparsed.txt");
open (FH2, ">>versions.txt");

use strict;
use Net::SSH::Perl;

my $user = $ARGV[0];
my $pass = $ARGV[1];
my $host = $ARGV[2];  #Hostname given as command line argument
my $cmd = "show version";
my $version;

print("\n");
print($ARGV[2]);
print("\n");

my $ssh = Net::SSH::Perl->new($host);
$ssh->login($user, $pass); # login to switch
my($stdout, $stderr, $exit) = $ssh->cmd($cmd);

printf FH ($stdout); #output all test to file

close(FH);

open(FH, "unparsed.txt");

while(<FH>){  #look through file for flash filename
    if($_ =~ /System image file is "(.*)"/){
            $version = $1;
    }
}

print ($version); #output flash filename
print ("\n");

printf FH2 ($ARGV[2]);
printf FH2 ("\n");
printf FH2 ($version);
printf FH2 ("\n");

close(FH2);

close(FH);

Upvotes: 0

Views: 1349

Answers (3)

salva
salva

Reputation: 10242

Try using Net::OpenSSH instead of Net::SSH::Perl.

Upvotes: 0

Diogo Constantino
Diogo Constantino

Reputation: 1

I prefer Net::SSH, and Net::SFTP::Foreign, math libs usally give me troubles when I try to install them on older systems (specially with the mess that some sysadmin do with paths on Unix systems). Most systems either use OpenSSH, or some fork of it (like SunSSH on Solaris), so it's less likely that you you'll have any sort of trouble using those distributions.

Upvotes: 0

Sinan &#220;n&#252;r
Sinan &#220;n&#252;r

Reputation: 118166

Crypt::DH loads Math::BigInt with:

use Math::BigInt lib => "GMP,Pari";

Therefore, you need either GMP or Pari on your system.

Your distribution's package manager may already provide a means to install them.

Have you tried using Net::SSH?

Upvotes: 2

Related Questions