Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

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 (Canon) 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 (Bishop) 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 the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (8)
As of 2021-04-21 15:13 GMT
Find Nodes?
    Voting Booth?

    No recent polls found