LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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
  Search this Thread
Old 10-30-2007, 01:29 PM   #1
cccc
Senior Member
 
Registered: Sep 2003
Distribution: Debian Squeeze / Wheezy
Posts: 1,623

Rep: Reputation: 51
cannot transfer files using Net::SFTP


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 10:51 AM.
 
Old 10-31-2007, 06:23 AM   #2
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,397

Rep: Reputation: 2777Reputation: 2777Reputation: 2777Reputation: 2777Reputation: 2777Reputation: 2777Reputation: 2777Reputation: 2777Reputation: 2777Reputation: 2777Reputation: 2777
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");
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
ssh login works but sftp doesn't... koyi Linux - Networking 10 03-12-2020 08:44 AM
install Net-SFTP perl module on debian etch cccc Debian 8 10-30-2007 09:47 AM
sftp with no login ryedunn Linux - Newbie 3 01-04-2007 09:27 PM
How do I use sftp to upload my web site? (no sftp tar command) johnMG Linux - Networking 6 06-21-2005 09:14 PM
Files truncated by sftp/sftp-server at 65kb gato Linux - Networking 1 12-18-2003 10:29 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:07 AM.

Main Menu
Advertisement
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
Twitter: @linuxquestions
Open Source Consulting | Domain Registration