http://www.perlmonks.org?node_id=664894

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

Hello
I´m having many problems to make a SSH connection works here. I'm using Windows. I tried to use Net::SSH::Perl but it generated the following error:
Can't set socket non-blocking: Bad file descriptor at C:/Perl/site/lib +/Net/SSH/Perl.pm line 216.
I tried to use Net::SSH::W32Perl but it generated the following error (Math::BigInt and Math::BigInt::FastCalc are installed):
Math::BigInt: couldn't load specified math lib(s), fallback to Math::B +igInt::FastCalc at C:/Perl/site/lib/Crypt/DSA/KeyChain.pm line 6 Math::BigInt: couldn't load specified math lib(s), fallback to Math::B +igInt::FastCalc at C:/Perl/site/lib/Crypt/DSA/Key.pm line 6 Math::BigInt: couldn't load specified math lib(s), fallback to Math::B +igInt::FastCalc at C:/Perl/site/lib/Crypt/DSA/Util.pm line 6 Not an ARRAY reference at C:/Perl/site/lib/Math/BigInt/Calc.pm line 25 +1.

Here is the code
#!/usr/bin/perl -w use Net::SSH::W32Perl; use Win32; $ENV{USERNAME} = Win32::LoginName(); $ENV{HOME} = Win32::GetFolderPath( Win32::CSIDL_PERSONAL ); $ip = 'x.x.x.x'; $ssh = Net::SSH::W32Perl->new($ip); $ssh->login("username","password"); ($out,$err,$ext) = $ssh->cmd("ls"); $ssh->close();

What am I doing wrong?

Replies are listed 'Best First'.
Re: Problems in Net::SSH
by zentara (Archbishop) on Jan 29, 2008 at 23:17 UTC
    couldn't load specified math lib(s)

    I don't use windows, but since no one else replied, I will edu-guess it's the old "library-version-binary-mismatch". In C (C++), in both linux and windows, the libraries need to be compiled so that they match. In linux, it is a small problem, because we have a free c compiler, so when we compile a module, it will be compatibility matched for our OS level, and basic c libraries. If on linux, you try to install a binary(pre-compiled) library, for a certain GLibc level, and the GLibc levels don't match with your particular OS, we get the same error.

    So on windows, you need to look at the version of windows that you are using, the version of ActiveStatePerl installed( assuming you use it), and the version of the module you downloaded. Usually, if you read the README files very carefully, they will say what versions of windows, and windows-based-perl are compatible. Also you must look at the compatibility of the pre-requisite libs that Net::SSH needs.

    Goodluck.


    I'm not really a human, but I play one on earth. Cogito ergo sum a bum
      I will edu-guess it's the old "library-version-binary-mismatch"

      No - the message is merely a response to an attempt to use (I think) Math::BigInt::GMP or (if that fails) Math::BigInt::Pari or (if that fails) Math::BigInt::BitVector. When those libs are unavailable, you get the messages that the OP quoted, and the pure-perl (slow) Math::BigInt is used instead. Nothing there that's going to cause any problems (except for speed of processing).

      I don't know if anyone here is interested in helping with Net::SSH::W32Perl - I know I'm definitely *not*. I have had some success on Windows with Net::SSH2 (available as a ppm from the uwinnipeg repository). Unfortunately, it too is less than ideal as there are some bugs with it on Windows - though I've so far managed to find workarounds for those bugs (in so far as they affect me). If cristianekw likes to give it a go, and has trouble, I'll try to help out.

      Cheers,
      Rob
        No - the message is merely a response to an attempt to use (I think) Math::BigInt::GMP or (if that fails) Math::BigInt::Pari or (if that fails) Math::BigInt::BitVector. When those libs are unavailable, you get the messages that the OP quoted, and the pure-perl (slow) Math::BigInt is used instead. Nothing there that's going to cause any problems (except for speed of processing).

        I re-installed these three libraries and then the login worked :)
        How did you know the libraries?
        Thanks!
Re: Problems in Net::SSH
by hesco (Deacon) on Sep 17, 2011 at 04:23 UTC

    Further in response to the monk who asked, How did you know? Before I read the response above me, I had readed for a cpan shell in search:

    cpan[9]> i /Math::BigInt/ Module = Math::BigInt (PJACKLAM/Math-BigInt-1.997.tar.gz) Module = Math::BigInt::Calc (PJACKLAM/Math-BigInt-1.997.tar.gz) Module = Math::BigInt::CalcEmu (PJACKLAM/Math-BigInt-1.997.tar.gz) Module Math::BigInt::Constant (TELS/math/Math-BigInt-Constant-1.08. +tar.gz) Module = Math::BigInt::FastCalc (PJACKLAM/Math-BigInt-FastCalc-0.30.t +ar.gz) Module = Math::BigInt::GMP (PJACKLAM/Math-BigInt-GMP-1.37.tar.gz +) Module Math::BigInt::Lite (FLORA/Math-BigInt-Lite-0.14.tar.gz) Module Math::BigInt::Named (TELS/math/Math-BigInt-Named-0.03.tar +.gz) Module Math::BigInt::Named::English (TELS/math/Math-BigInt-Named-0. +03.tar.gz) Module Math::BigInt::Named::German (TELS/math/Math-BigInt-Named-0.0 +3.tar.gz) Module = Math::BigInt::Pari (PJACKLAM/Math-BigInt-Pari-1.17.tar.g +z) Module Math::BigInt::Parts (PJACKLAM/Math-BigInt-Parts-0.02.tar. +gz) Module Math::BigInt::Random (BILLH/Math-BigInt-Random-0.04.tar.gz +) Module Math::BigInt::Random::OO (PJACKLAM/Math-BigInt-Random-OO-0.0 +3.tar.gz) Module < Math::BigInt::Trace (FLORA/bignum-0.29.tar.gz) Module Math::BigIntFast (N/A) 16 items found

    And was able to get that close before doing a search which brought me back to the monestary. And by the way folks, my deep appreciation to all the wonderful folks in this brother and sister hood between these cloistered walls. I'm closing in on the six month point under my first ever contract to a perl code shop. Its been a tremendous learning experience. And I never would have had that opportunity if not for the support and guidance provided by this community when I reached out ready to learn perl.

    -- Hugh Esco

    if( $lal && $lol ) { $life++; }
    if( $insurance->rationing() ) { $people->die(); }