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

I have downloaded all the necessary packages (I believe), for trying to run OpenSSH a simple OpenSSH script. However everytime I try to run it, or output the warnings, below is what I am getting.

I have looked at this, and think that the issue may lie as suggested in the warning in the OpenSSH.pm file...? Is that right, or am I way off base on this? Thanks for your help...

use Net::OpenSSH; my $host = 'server'; my $userid = 'userid'; my $pass = 'password'; my $ssh = Net::OpenSSH->new('$host');

Here is the warning output:

Subroutine Cwd::fastcwd redefined at C:/Perl/lib/Cwd.pm line 753.

Subroutine Cwd::getcwd redefined at C:/Perl/lib/Cwd.pm line 753.

Subroutine Cwd::abs_path redefined at C:/Perl/lib/Cwd.pm line 753.

Use of uninitialized value in anonymous hash ({}) at C:/Perl/site/lib/Net/OpenSSH.pm line 196.

Use of uninitialized value in anonymous hash ({}) at C:/Perl/site/lib/Net/OpenSSH.pm line 196.

Use of uninitialized value in anonymous hash ({}) at C:/Perl/site/lib/Net/OpenSSH.pm line 196.

Use of uninitialized value in anonymous hash ({}) at C:/Perl/site/lib/Net/OpenSSH.pm line 196.

Use of uninitialized value in anonymous hash ({}) at C:/Perl/site/lib/Net/OpenSSH.pm line 196.

Use of uninitialized value in anonymous hash ({}) at C:/Perl/site/lib/Net/OpenSSH.pm line 196.

Use of uninitialized value in anonymous hash ({}) at C:/Perl/site/lib/Net/OpenSSH.pm line 196.

Use of uninitialized value in anonymous hash ({}) at C:/Perl/site/lib/Net/OpenSSH.pm line 196.

Odd number of elements in anonymous hash at C:/Perl/site/lib/Net/OpenSSH.pm line 196.

Line 196 is the following in the OpenSSH.pm file

_home => do { local $SIG{__DIE__}; local $SIG{__WARN__}; local $@; eval { Cwd::realpath((getpwuid $>)[7]) } },

I have Net-OpenSSH V.38 with ActivePerl version 5.8.9.826

Replies are listed 'Best First'.
Re: NET::OpenSSH not working...
by Corion (Patriarch) on Jun 30, 2010 at 19:58 UTC

    I can't verify this, as Net::OpenSSH refuses to install on my Windows machine/Strawberry Perl.

    Are you getting that error with the exact five lines you posted above? If not, you have somewhere a line like this in your code:

    use cwd;

    Note the lowercase "c".

    This is wrong, as Perl modules are case-sensitive. As you are on a case-insensitive (but case-preserving) filesystem, Perl will still find a file cwd.pm and load it, but thinks it does not have Cwd.pm loaded. When Net::OpenSSH requests to load Cwd.pm, Perl tries to load it and then overwrites the definitions in the Cwd:: namespace.

      I am getting the error with the exact five lines I posted above. Interestingly enough, if I add the use cwd; line I get even more warnings. The output for that is below. I am trying to just get the ssh piece working before doing anything else, so the code is simply the 5 lines.

      Subroutine Cwd::fastcwd redefined at C:/Perl/lib/cwd.pm line 753.

      Subroutine Cwd::getcwd redefined at C:/Perl/lib/cwd.pm line 753.

      Subroutine Cwd::abs_path redefined at C:/Perl/lib/cwd.pm line 753.

      Subroutine _carp redefined at C:/Perl/lib/Cwd.pm line 317.

      Subroutine _croak redefined at C:/Perl/lib/Cwd.pm line 318.

      Subroutine _backtick_pwd redefined at C:/Perl/lib/Cwd.pm line 321.

      Subroutine _perl_getcwd redefined at C:/Perl/lib/Cwd.pm line 378.

      Subroutine fastcwd_ redefined at C:/Perl/lib/Cwd.pm line 389.

      Subroutine chdir_init redefined at C:/Perl/lib/Cwd.pm line 437.

      Subroutine chdir redefined at C:/Perl/lib/Cwd.pm line 461.

      Subroutine _perl_abs_path redefined at C:/Perl/lib/Cwd.pm line 504.

      Subroutine fast_abs_path redefined at C:/Perl/lib/Cwd.pm line 582.

      Subroutine _vms_cwd redefined at C:/Perl/lib/Cwd.pm line 643.

      Subroutine _vms_abs_path redefined at C:/Perl/lib/Cwd.pm line 647.

      Subroutine _os2_cwd redefined at C:/Perl/lib/Cwd.pm line 684.

      Subroutine _win32_cwd redefined at C:/Perl/lib/Cwd.pm line 691.

      Subroutine _dos_cwd redefined at C:/Perl/lib/Cwd.pm line 704.

      Subroutine _qnx_cwd redefined at C:/Perl/lib/Cwd.pm line 715.

      Subroutine _qnx_abs_path redefined at C:/Perl/lib/Cwd.pm line 724

      Subroutine _epoc_cwd redefined at C:/Perl/lib/Cwd.pm line 739.

      Subroutine Cwd::fast_realpath redefined at C:/Perl/lib/Cwd.pm line 630.

      Subroutine Cwd::_NT_cwd redefined at C:/Perl/lib/Cwd.pm line 702.

      Subroutine Cwd::fastgetcwd redefined at C:/Perl/lib/Cwd.pm line 753.

      Subroutine Cwd::realpath redefined at C:/Perl/lib/Cwd.pm line 753.

      Subroutine Cwd::fastcwd redefined at C:/Perl/lib/Cwd.pm line 753

      .

      Subroutine Cwd::cwd redefined at C:/Perl/lib/Cwd.pm line 753.

      Subroutine Cwd::getcwd redefined at C:/Perl/lib/Cwd.pm line 753.

      Subroutine Cwd::abs_path redefined at C:/Perl/lib/Cwd.pm line 753.

      Use of uninitialized value in anonymous hash ({}) at C:/Perl/site/lib/Net/OpenSSH.pm line 196.

      Use of uninitialized value in anonymous hash ({}) at C:/Perl/site/lib/Net/OpenSSH.pm line 196.

      Use of uninitialized value in anonymous hash ({}) at C:/Perl/site/lib/Net/OpenSSH.pm line 196.

      Use of uninitialized value in anonymous hash ({}) at C:/Perl/site/lib/Net/OpenSSH.pm line 196.

      Use of uninitialized value in anonymous hash ({}) at C:/Perl/site/lib/Net/OpenSSH.pm line 196.

      Use of uninitialized value in anonymous hash ({}) at C:/Perl/site/lib/Net/OpenSSH.pm line 196.

      Use of uninitialized value in anonymous hash ({}) at C:/Perl/site/lib/Net/OpenSSH.pm line 196.

      Use of uninitialized value in anonymous hash ({}) at C:/Perl/site/lib/Net/OpenSSH.pm line 196.

      Odd number of elements in anonymous hash at C:/Perl/site/lib/Net/OpenSSH.pm line 196.

      To add to the note I said earlier. If I do add the use Cwd; with uppercase C, the warnings come out the same as in my original issue.

Re: NET::OpenSSH not working...
by salva (Canon) on Jun 30, 2010 at 20:05 UTC
    I have Net-OpenSSH V.38 with ActivePerl

    Net::OpenSSH does not work on Windows because the port of OpenSSH for that OS lacks some features required by the module (for instance, multiplexing several sessions over the same connection).

    Net::SSH2 is probably your best option there.