LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
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-31-2011, 02:36 PM   #1
giantanakim
LQ Newbie
 
Registered: Oct 2011
Posts: 23

Rep: Reputation: Disabled
Trouble scripting SFTP transfer.


Hi everyone: I am running into a wall with this one. I have developed a bash script to upload wav files to an sftp server. Here is what I have developed so far:

Code:
#!/usr/bin/perl -w
use Net::SFTP::Foreign;
#use strict;
use warnings;
my $host = "12.12.12.12";
my %args = (
	user => 'upload',
	password => 'wavs',
	);
my $sftp = Net::SFTP::Foreign->new($host, %args, more => '-v');
$sftp->mkdir ("/test");
$sftp->put ("~/Documents/testftp.txt", "/test/testftp.txt");
Here is what I get from the verbose mode:

OpenSSH_5.8p1 Debian-7ubuntu1, OpenSSL 1.0.0e 6 Sep 2011
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Applying options for *
debug1: Connecting to 12.12.12.12 [12.12.12.12] port 22.
debug1: Connection established.
debug1: identity file /home/user/.ssh/id_rsa type -1
debug1: identity file /home/user/.ssh/id_rsa-cert type -1
debug1: identity file /home/user/.ssh/id_dsa type -1
debug1: identity file /home/user/.ssh/id_dsa-cert type -1
debug1: identity file /home/user/.ssh/id_ecdsa type -1
debug1: identity file /home/user/.ssh/id_ecdsa-cert type -1
debug1: Remote protocol version 2.0, remote software version OpenSSH_5.5p1 Debian-6
debug1: match: OpenSSH_5.5p1 Debian-6 pat OpenSSH*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_5.8p1 Debian-7ubuntu1
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr hmac-md5 none
debug1: kex: client->server aes128-ctr hmac-md5 none
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<1024<8192) sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
debug1: Server host key: RSA xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx


After I receive that, it goes back to the standard command prompt. When I try to verify transfer by connecting via a Filezilla, nothing has been created or transferred. Any tips as to what I am missing?
 
Old 10-31-2011, 05:36 PM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Can't you use snailbook's I want to use sftp in a script nfo instead? Explains all and w/o needing Perl modules. If you however would like to pursue your approach what does the server side SSH daemon log say?
 
Old 11-07-2011, 01:05 PM   #3
giantanakim
LQ Newbie
 
Registered: Oct 2011
Posts: 23

Original Poster
Rep: Reputation: Disabled
Thanks for your help. I was actually able to figure out what was causing the issue. For some reason the script was not accepting the server assigned key. Once I logged in manually through the terminal and accepted the key, everything is now working properly.

Thanks again.
 
  


Reply



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
[SOLVED] Transfer files in sftp xeon123 Linux - Networking 7 12-17-2010 11:04 AM
SFTP throwing "End of file" when doing SFTP transfer in perl exceed1 Programming 5 03-06-2010 01:34 PM
File transfer using SFTP santhoshv Linux - Networking 1 09-18-2008 06:33 AM
Can transfer only 2MB using sftp nIMBVS Debian 1 11-26-2005 03:26 PM
sftp: how to transfer the whole directory? kpachopoulos Linux - General 1 11-06-2005 08:44 AM

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

All times are GMT -5. The time now is 02:46 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