LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
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-07-2010, 10:09 PM   #1
moodah
LQ Newbie
 
Registered: Sep 2010
Posts: 15

Rep: Reputation: 1
SFTP file upload bash script issue.


Hi all.

I have a requirement to upload a file to a business partner of ours in another country.

Currently they have an SFTP server set up for us that I am using to download a daily generated file from a previous requirement. I use a bash script to download it since its fairly simple.

Quote:
sftp username@address/filename_filedate.zip /home/user/filedirectory > /var/log/joblog
(removed private info)

To satisfy the new requirement I have been trying to write something similar to this;

Quote:
sftp /home/user/filedirectory/filename_filedate.zip username@address:/remotedirectory/
Can anyone tell me if this is even possible? sftps manual page only gives a hint about using a batchfile, however i still cannot get it to work. Does anyone know another way? Or if you can even suggest another method or application? It seems like a bit of a cop out you can EASILY download using the sftp command but can't upload.

EDIT - forgot to mention I have already got keyless entry set up using ssh keys.

Last edited by moodah; 10-07-2010 at 10:10 PM. Reason: moar info
 
Old 10-07-2010, 10:55 PM   #2
moodah
LQ Newbie
 
Registered: Sep 2010
Posts: 15

Original Poster
Rep: Reputation: 1
Hi guys - I figured it out and finished the script.

sftp -b 'scriptfile' 'username'@'server' is required.

In the top of my script I make it output a temporary text file 'scriptfile' that the below half of the script will then use in the above command.


In my case, the errors I was getting was due to the directory i was trying to ftp didnt exist. Id been told the wrong directory in this case which was hugely annoying. I found out because I sftp'd into the directory I knew worked and checked from there.
 
1 members found this post helpful.
  


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
script to sftp file to remote server OzTEXS Linux - Newbie 6 06-23-2013 05:33 PM
issue in using private key file in bash script manya Programming 3 08-24-2009 01:49 AM
Bash script for batch upload files on server dotcom22 Linux - Server 7 07-28-2009 05:18 AM
limit upload/download file size in SFTP bzlaskar Linux - Server 2 02-28-2009 11:25 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

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

All times are GMT -5. The time now is 04:32 PM.

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