Automatic FTP-Download | not files older then x days

Hey Guys,

i need to download files from a ftp-server that not older than $VAR (x) days

eg for seven days
./script 7

or two weeks
./script 14

all files from the last 14 days will download but how i can explain "ftp" this?

sorry for my strange english :confused:

ftp itslef is not file date aware so what you are going to have to is an ls of the files on the ftp server, log that to a file on your local machine filter for the dates of interest, pull out the file names and the get those files.

The .netrc file in the local user's home directory can be configured with the username and password, the following web page:
http://rcsg-gsir.imsb-dsgi.nrc-cnrc.gc.ca/documents/internet/node52.html
covers providing the commands to the ftp command using here text.

i do not know how to filter the txt-file :slight_smile:

if i connected to the ftp i can do "ls -R" and become the complete dirlist of ftp-server ... this i can save i a local file but ... how i filter the crap

---------- Post updated 25-01-10 at 04:53 AM ---------- Previous update was 24-01-10 at 04:51 PM ----------

thanks for reply :slight_smile:

i found a interesting blogpost.

apt-get install curlftpfs
#!/bin/sh
curlftpfs -s ftp://user:pass@testdomainbla.de /mnt/ftpverz
rsync -rltDvz --force --exclude-from=rsync_exclude.txt /var/www/webprojekt/ /mnt/ftpverz/
umount /mnt/ftpverz

now i can mount the ftp-server-DIR and "find" only the newest files:

# mount the ftp in a directory
curlftpfs -s ftp://user:pass@host.de /root/test

# possible script for me
LISTING=$(ls -t /root/test/ | head -5)

# test
echo $LISTING

webalizer
ftp.php
moo.png
pn.png
footer.png

now i have saved all ftp-files in a variable ($LISTING)

the only thing i do not know ... how i can list only the
newest files ... of the last XX (eg 14) days. don't know
the parameter for "find" ... can any help?

or i test it with "rsync" ? :slight_smile:

edit soon