sftp on windows XP

Posted by seizner on 2009-09-22 13:00
Forums: PPM | OS: Windows XP Pro

I'm trying to write a programm that will sftp files fro Windows XP platform.

I cannot find Net::SFTP module on ppm, only Net::SFTP::Foreign is available.

When I try to use it I have the following error:
password authentication is not available, IO::Pty and Expect are not installed at G:\DWH\CONE\sftpTest.pl line 9

I cannot find both IO:Pty and Expect on ppm.

Please help.

Here is my code:

use strict;
use Net::SFTP::Foreign;
my $host;
my %fargs;

%fargs = ( user => "usercode", password => 'password');
my $sftp = Net::SFTP::Foreign->new($host, %fargs);


sdetweil | Thu, 2009-09-24 07:22

I used CPAN to load Net::SFTP and its dependancies (a ton of them)

Net::SFTP uses Net::SSH::Perl which has a bug reported on a loop in the data handling (client to server).. no known fix for the loop yet..


seizner | Tue, 2009-09-29 11:09

Did you succeed to run it?

samir | Thu, 2009-11-12 13:46

Hi - I guess I'm encountering the same issue as you. Net::SFTP::Foreign produces the IO:Pty error, and Net::SFTP is just hanging.

Did you find a solution?

lmaslow | Mon, 2010-07-26 09:35

I have the same problem about installing expect and IO::Pty. i have downloaded it and still have the problem. can anyone explain to me what directory i should put the expect.pm and pty.pm

lovedada | Thu, 2010-11-11 09:21

To cut a long story short, Net::SFTP won't work on windows because it needs to be changed to use Net::SSH::W32Perl instead of Net::SSH::Perl. However, Net::SSH::W32Perl also needs fixing because it's trying to re-define methods in Net::SSH::Perl that have been renamed since it was written.

The changes required are below


< use Net::SSH::Perl 1.24;
> ## DL Change from Net::SSH::Perl to Net::SSH::W32Perl here
> ##use Net::SSH::Perl 1.24;
> use Net::SSH::W32Perl 1.24;
< my $ssh = Net::SSH::Perl->new($sftp->{host}, protocol => 2,
> ## DL Change from Net::SSH::Perl to Net::SSH::W32Perl here
> ##my $ssh = Net::SSH::Perl->new($sftp->{host}, protocol => 2,
> my $ssh = Net::SSH::W32Perl->new($sftp->{host}, protocol => 2,


> ## DL Added method below since method protocol_class that
> ## is meant to be re-defined above no longer exists...
> sub set_protocol {
> return shift->SUPER::set_protocol(@_) unless IS_WIN32;
> die "SSH2 is the only supported protocol under MSWin32!"
> unless (PROTOCOL_SSH2 == $_[1]);
> my $ssh = shift;
> my $proto = shift;
> $ssh->{use_protocol} = $proto;
> my $proto_class = "Net::SSH::W32Perl::SSH2";
> (my $lib = $proto_class . ".pm") =~ s!::!/!g;
> require $lib;
> bless $ssh, $proto_class;
> $ssh->debug($proto_class->version_string);
> $ssh->_proto_init;
> }

pjack101 | Tue, 2010-12-21 13:52

i found just what i was looking for here via google,thanks guys