Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses

Downloading files from SFTP in windows

by sankarg (Initiate)
on Jan 02, 2013 at 10:30 UTC ( #1011244=perlquestion: print w/replies, xml ) Need Help??
sankarg has asked for the wisdom of the Perl Monks concerning the following question:

Dear Monks, New Year wishes.

I need to download files to one location and upload files from another location to a specified path in SFTP. I am using windows OS and i tried with Perl module Net::SFTP but it doesn't works for me. I used the below code to connect the SFTP server but i failed with this. Kindly help me to connect the SFTP server.

use strict; use Net::SFTP; my $host = ""; my %args = ( user => 'username', password => 'password', debug => 'false' ); my $sftp = Net::SFTP->new($host, %args); print "connected!";

This is the error i got from the script. "Can't map service name 'ssh' to port number at C:/Perl/site/lib/Net/ line 61"

Replies are listed 'Best First'.
Re: Downloading files from SFTP in windows
by tobyink (Abbot) on Jan 02, 2013 at 10:56 UTC

    Net::SFTP appears to use the getservbyname function to map a service name and protocol ("ssh", "tcp") to a port (22). The getservbyname function looks up the service name in the system's services file.

    On Unix this is typically /etc/services. On Windows, it's typically C:\Windows\System32\drivers\etc\services. Make sure that this file exists, and "ssh" is listed correctly.

    perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'
Re: Downloading files from SFTP in windows
by saberworks (Curate) on Jan 02, 2013 at 16:17 UTC
    If you can't get Net::SFTP to work, try Net::SFTP::Foreign, which can wrap ssh/sftp binaries you might already have on your system (for example, putty). I've had good luck with Net::SFTP::Foreign on windows.
Re: Downloading files from SFTP in windows
by syphilis (Chancellor) on Jan 02, 2013 at 17:48 UTC
    On Windows I use Net::SFTP::Foreign::Backend::Net_SSH2.
    It works well.


Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1011244]
Front-paged by Arunbear
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (4)
As of 2017-01-20 06:40 GMT
Find Nodes?
    Voting Booth?
    Do you watch meteor showers?

    Results (173 votes). Check out past polls.