Unfortunately I forgot to mention a crucial point about the function I am 
trying to code for. 

The source Windows server from which the files have to be copied is external to 
our organisation - the server belongs to a third party. The server is open for 
SFTP transfers on a specified port only, so any solution requiring an SSH 
connection is not going to work - unless the third party changes their 
architecture which is unlikely.

My reading of this is that any solution that requires an SSH connection 
(including NET::SFTP::Foreign and other ActiveState modules which explicitly 
call an ssh executable to establish a connection) is not going to fly.

The module Net:FTPSSL would appear to be a solution but it is not on 
ActiveState and attempts to download and install it manually from CPAN have 
failed.

So I am still open to any alternative solutions, or words of advice from anyone 
who has managed to successfully install Net::FTPSSL.

Regards,
@shley

-----Original Message-----
From: Sisyphus [mailto:sisyph...@optusnet.com.au] 
Sent: Thursday, 27 August 2009 1:30 PM
To: Ashley Cooper; beginners@perl.org
Subject: Re: SFTP from Perl for Windows


----- Original Message ----- 
From: "Sisyphus" <sisyph...@optusnet.com.au>

> Adapted (and untested) from an actual script I use:
> ##############################
> use warnings;
> use strict;
> use Net::SSH2;
>
> my $server = 'server.nameer';
> my $ssh2 = Net::SSH2->new;
> die "can't connect" unless $ssh2->connect($server);
>
> print "Connected\n";
>
> die "can't authenticate"
> unless $ssh2->auth(username => 'user',
>                    password => 'pass');
>
> print "Authenticated\n";
>
> my $sftp = $ssh2->sftp;
> $ssh2->debug(1);
>
> my @files = qw (file1 file2 file3);
> my $dir = '/directory/on/server';
>
> #Upload
> for(@files) {
>   $ssh2->scp_put($_, "$dir/$_");
> }
>
> $ssh2->disconnect();
> ##########################

Hmmm ... not a very good adaptation - it actually uses scp, and $sftp is 
used only once.
See how you get on with it.

Cheers,
Rob 


***********************************************************************************
This e-mail, including any attachments to it, may contain confidential and/or 
personal information. If you have received this e-mail in error, you must not 
copy, distribute, or disclose it, use or take any action based on the 
information contained within it. Please notify the sender immediately by return 
e-mail of the error and then delete the original e-mail.

The information contained within this e-mail may be solely the opinion of the 
sender and may not necessarily reflect the position, beliefs or opinions of the 
organisation on any issue. This email has been swept for the presence of 
computer viruses known to the organisation’s anti-virus systems.

***********************************************************************************


Reply via email to