in reply to Latest version of Perl - includes SFTP?

As far as I know Net::SFTP and Net::SSH::Perl are not part of the core.
From my experience installing Net::SSH::Perl is a bit tedious. Install the prerequisite modules beforehand (at least those having Math namespace) thus you avoid possible hurdles with complex dependencies.

I use Net::SSH::Perl on Solaris OSs without any issues.
  • Comment on Re: Latest version of Perl - includes SFTP?

Replies are listed 'Best First'.
Re^2: Latest version of Perl - includes SFTP?
by deansleonard (Initiate) on Dec 23, 2007 at 06:56 UTC
    Here's what I had to do to install Net::SSH::Perl in my Windows ActivePerl 5.6.1 environment:

    1. Use PPM3 to set the proper repository and install net-ssh-perl

    ppm> rep add "U of Winnipeg" http://theoryx5.uwinnipeg.ca/ppms/package.xml
    ppm> install net-ssh-perl -force –follow

    2. Get Math-GMP-2.04 from CPAN.org and untar it. Build fails due to missing 'gmp.h' and 'gmp.lib' files, so you have to build 'em.

    3. Get GMP from http://cs.nyu.edu/exact/core/gmp/ and follow instructions to build based on how your version of ActivePerl was built. My ActivePerl 5.6.1 was built using Microsoft VC, with ccflags including '-MD', so I followed the instructions for building GMP using this compiler, changing Project…Settings…C/C++…Project Options to use /MD instead of /ML. The build completes with 0 Erros and 132 Warnings.

    4. Copy the resulting gmp.h and gmp.lib to the untarred Math-GMP-2.04 directory. Then build Math-GMP-2.04 using the standard Makefile.PL...nmake...nmake test...nmake install process.

    5. Edit <perl>/site/lib/Net/SSH/Perl.pm and comment out these lines if you get the "Can't set socket non-blocking" error message:

    # defined($sock->blocking(0))
    # or die "Can't set socket non-blocking: $!";

    Here's a test script you can use:

    use Getopt::Std; use Net::SSH::Perl; &getopts('h:u:p:'); &Usage( ) unless( defined($opt_h) && defined($opt_u) && defined($opt_p +) ); $ssh = Net::SSH::Perl->new( $opt_h, port => 22 ); $ssh->login( $opt_u, $opt_p ); while( 1 ) { print "$opt_h\> "; $cmd = <STDIN>; $cmd =~ s/^\s+|\s+$//g; last if( $cmd eq "" ); ($stdout, $stderr, $exit_code) = $ssh->cmd($cmd); if( $exit_code ) { print $stderr; } else { print $stdout; } } exit( 0 ); sub Usage { print “Usage: $0 -h <host> -u <user> -p <password>\n”; exit( 0 ); } # end of Usage
    HTH,
    Dean Leonard