develooper Front page | perl.beginners | Postings from August 2009

RE: SFTP from Perl for Windows

Thread Previous | Thread Next
From:
Ashley Cooper
Date:
August 26, 2009 20:37
Subject:
RE: SFTP from Perl for Windows
Message ID:
4A133BBC82A97C42A9CC3BB41C4620CA17CC6AD6@sydmxs01.salmat.com.au
I can see a Net::SSH on ActiveState, but not Net::SSH2. Is this the same thing?

Regards,
@shley

-----Original Message-----
From: Sisyphus [mailto:sisyphus1@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" <sisyphus1@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.

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



Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About