LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Thread Tools
Old 10-30-2007, 02:29 PM   #1
cccc
Member
 
Registered: Sep 2003
Posts: 822
Thanked: 2
cannot transfer files using Net::SFTP


[Log in to get rid of this advertisement]
hi

we're using Public/Private Key authentication between SFTP client and server to trnasfer files.
I can login into SFTP server from my client linux debian machine without problems using this command:

# sftp user@server (without password)


but if i try to use a Net::SFTP perl script it doesn't work:
Code:
#!/usr/bin/perl -w

use strict;
use warnings;

use Net::SFTP;

my $server="X.X.X.X";

my $user="myuser";

my $password="";

my %args = (user => "$user", password => "$password", ssh_args => [port => 22]);

my $file="TEST.CSV";

my $sftp=Net::SFTP->new($server, %args);

$sftp->put($file);

exit;
TEST.CSV is there, at the same directory.

I get the following error:
Code:
# perl test.cgi
Use of uninitialized value in concatenation (.) or string at /usr/local/share/perl/5.8.8/Net/SFTP.pm line 245.
Couldn't get handle: No such file or directory at test.cgi line 20
howto solve this problem ?

Last edited by cccc; 10-31-2007 at 11:51 AM..
cccc is offline     Reply With Quote
Old 10-31-2007, 07:23 AM   #2
chrism01
Guru
 
Registered: Aug 2004
Location: Brisbane
Distribution: Centos 5.4
Posts: 7,429
Thanked: 325
A few things occur to me:

1. the '-w' switch and 'use warnings;' do the same thing (FYI), so only 1 is reqd.

2. you're not checking for errors at all eg calling the new and put methods.

3. The cpan page says this pm is only good for SSH v2 protocol. (Net::SFTP is a pure-Perl implementation of the Secure File Transfer Protocol (SFTP) - file transfer built on top of the SSH2 protocol.)
Are you sure you systems are using this.?

4. the cpan page also seems to show that the remote filename is not optionalk in the put method eg: $sftp->put("bar", "baz");
chrism01 is offline     Reply With Quote

Reply

Bookmarks


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
install Net-SFTP perl module on debian etch cccc Debian 8 10-30-2007 10:47 AM
sftp with no login ryedunn Linux - Newbie 3 01-04-2007 10:27 PM
ssh login works but sftp doesn't... koyi Linux - Networking 7 10-24-2006 12:19 PM
How do I use sftp to upload my web site? (no sftp tar command) johnMG Linux - Networking 6 06-21-2005 10:14 PM
Files truncated by sftp/sftp-server at 65kb gato Linux - Networking 1 12-18-2003 11:29 AM


All times are GMT -5. The time now is 11:33 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
RSS2  LQ Podcast
RSS2  LQ Radio
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration