Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

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 = "xxx.xxx.xxx.xxx"; 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/SFTP.pm line 61"

Comment on Downloading files from SFTP in windows
Download Code
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 (Canon) on Jan 02, 2013 at 17:48 UTC
    On Windows I use Net::SFTP::Foreign::Backend::Net_SSH2.
    It works well.

    Cheers,
    Rob

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1011244]
Front-paged by Arunbear
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (5)
As of 2014-10-24 23:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (138 votes), past polls