Create a gist now

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Loop to download a file from FTP, create a symlink to the file and append date and time to subsequent downloads...

Bash script to download file from FTP

Loop to download a file from FTP, create a symlink to the file and append date and time to subsequent downloads...

#!/bin/bash
# open loop
while true
# open the loop action
do
# sets date to date
DATE=`date +%Y%m%d%H%M%S`
# hits ftp and downloads
curl -o $DATE-<FILE NAME HERE> ftp://<USERNAME HERE>:<PASSWORD HERE>@<FTP PATH HERE>
# remove the file
rm <FILE NAME HERE>
# hits ftp and downloads
ln -s $DATE-<FILE NAME HERE> <FILE NAME HERE>
# rests for a minute
sleep 120
# close the loop action
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment