LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Enterprise Linux Forums > Linux - Enterprise
User Name
Password
Linux - Enterprise This forum is for all items relating to using Linux in the Enterprise.

Notices


Reply
  Search this Thread
Old 07-30-2019, 10:05 AM   #1
beeblequix
Member
 
Registered: Oct 2005
Location: Tierra Firma, Earth
Distribution: Debian of course...
Posts: 198

Rep: Reputation: 30
Need help with lftp to automate file transfers


Howdy Folks,

For the longest time I've been using a "here" statement with the old ftp program on SLES 8-11 to automate file transfers from my server to another location by calling a function similar to this in my bash scripts:

function ftp_my_file {
/usr/bin/ftp -A -n <<here
open some.ip.address
user my_username my_password
epsv4
bin
put $FILE_TO_FTP
quit
here
}

This function has worked fine up until we upgraded to SLES 12 and the old FTP program was replaced with Lftp which doesn't use the same syntax. Does someone have a method in a script using lftp that does the same thing? Thanks.
 
Old 07-30-2019, 10:17 AM   #2
scasey
LQ Veteran
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.9.2009
Posts: 5,732

Rep: Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212
Quote:
Originally Posted by beeblequix View Post
Howdy Folks,

For the longest time I've been using a "here" statement with the old ftp program on SLES 8-11 to automate file transfers from my server to another location by calling a function similar to this in my bash scripts:

function ftp_my_file {
/usr/bin/ftp -A -n <<here
open some.ip.address
user my_username my_password
epsv4
bin
put $FILE_TO_FTP
quit
here
}

This function has worked fine up until we upgraded to SLES 12 and the old FTP program was replaced with Lftp which doesn't use the same syntax. Does someone have a method in a script using lftp that does the same thing? Thanks.
Scanning the man lftp page, I don't see any difference in the syntax except, perhaps, for the syntax for epsv.
I also note that binary is the default transfer mode, but the syntax to specify that is also different in lftp.

The HERE document should continue to work once you modify the commands accordingly.

Suggest you review man lftp. It should be easy enough to convert your script.
 
Old 07-30-2019, 02:16 PM   #3
beeblequix
Member
 
Registered: Oct 2005
Location: Tierra Firma, Earth
Distribution: Debian of course...
Posts: 198

Original Poster
Rep: Reputation: 30
I got it to work in my bash script --

lftp -e "set ftp:ssl-allow off; put $FILE_TO_FTP -o /fully/qualified/path/to/network/drive/$FILE_TO_FTP; bye" -u my_username,my_password some.ftpserver.local


Note 1: if I pass along the password like this and the password contains special characters then escape them.
Note 2: it's probably better to use ~/.netrc to store credentials. Will explore this.
Note 3: initially I kept getting stuck on "making data connection". The "set ftp:ssl-allow off;" part prevents it from trying to use SSL.
 
Old 07-30-2019, 04:03 PM   #4
scasey
LQ Veteran
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.9.2009
Posts: 5,732

Rep: Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212
Quote:
Originally Posted by beeblequix View Post
I got it to work in my bash script --

lftp -e "set ftp:ssl-allow off; put $FILE_TO_FTP -o /fully/qualified/path/to/network/drive/$FILE_TO_FTP; bye" -u my_username,my_password some.ftpserver.local


Note 1: if I pass along the password like this and the password contains special characters then escape them.
Note 2: it's probably better to use ~/.netrc to store credentials. Will explore this.
Note 3: initially I kept getting stuck on "making data connection". The "set ftp:ssl-allow off;" part prevents it from trying to use SSL.
.netrc is definitely the better way to go. You now not only have your password in the clear in the script, but it's probably visible in the output of a ps command while the transfer is running

Last edited by scasey; 07-30-2019 at 08:56 PM.
 
  


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
nextcloud - support for UDP file transfers or faster TCP file transfers robertkwild CentOS 0 10-20-2017 10:57 PM
Automate FTP / Scripting FTP Transfers files from linux to windows m/c ashishshukla Programming 5 05-26-2016 09:10 AM
Need a little help in making a script to help automate unraring steve51184 Linux - Software 2 02-01-2014 04:33 PM
Need help with wild card syntax to semi-automate file conversion using a perl script kmkocot Linux - Newbie 5 12-12-2007 01:55 PM
LXer: Speaking Unix, Part 6: Automate, automate, automate! LXer Syndicated Linux News 0 01-04-2007 09:54 AM

LinuxQuestions.org > Forums > Enterprise Linux Forums > Linux - Enterprise

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