| Store | Cart

Re: SFTP

From: <sisy...@optusnet.com.au>
Tue, 28 Oct 2014 13:04:45 +1100
From: Schwartz, Peter W
Sent: Tuesday, October 28, 2014 2:44 AM
To: perl...@listserv.ActiveState.com
Subject: SFTP

> I’m trying to locate an SFTP install for Windows (32-bit) but I can’t seem > to find anything in the PPM for some reason.  Does anyone have any > recommendations on how to get this for Windows?
You can do SFTP with Net::SSH2 - which is now part of Strawberry Perl.
Or, if you don't have Net::SSH2 you can:
ppm install http://www.sisyphusion.tk/ppm/Net-SSH2.ppd --force

However, the Net::SSH2 user interface is a bit awkward, so the nicest way to 
utilise that module (and this is how I use it) is to then:

ppm install http://www.sisyphusion.tk/ppm/Net-SFTP-Foreign.ppd --force
ppm install 
http://www.sisyphusion.tk/ppm/Net-SFTP-Foreign-Backend-Net_SSH2.ppd --force

(Those last 2 are pure-perl and just as simple to install using 'cpan -i' or 
similar, if you want. The reason we use --force is explained at
http://www.sisyphusion.tk/faq.html )

That done, it's just a matter of something like:

#############################################
use strict;
use warnings;
use Net::SFTP::Foreign;

$ftp = Net::SFTP::Foreign->new
  (host => $server,
   backend => 'Net_SSH2',
   user => $user,
   password => $pass,
   );
$ftp->error and die "Unable to establish SFTP connection: ". $ftp->error;
print "Connected to the SFTP server (and authorised)\n";

$ftp->put($local_file, $remote_file) or die $ftp->error;
$ftp->get($rem_file, $loc_file) or die $ftp->error;

$ftp->disconnect;

#############################################

Works well for me.

Cheers,
Rob

_______________________________________________
Perl-Win32-Users mailing list
Perl...@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Recent Messages in this Thread
Schwartz, Peter W Oct 27, 2014 03:44 pm
Ashley Hoff Oct 27, 2014 10:05 pm
Mike Malony Oct 27, 2014 10:52 pm
Schwartz, Peter W Oct 27, 2014 10:53 pm
Ashley Hoff Oct 27, 2014 11:02 pm
Justin Allegakoen Oct 28, 2014 01:01 am
sisy...@optusnet.com.au Oct 28, 2014 02:04 am
Will...@L-3Com.com Oct 28, 2014 11:11 am
Messages in this thread

Previous post: Re: SFTP
Next post: RE: SFTP