Automatic FTP-Download | not files older then x days


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Automatic FTP-Download | not files older then x days
# 1  
Old 01-24-2010
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 :/
# 2  
Old 01-24-2010
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....et/node52.html
covers providing the commands to the ftp command using here text.
# 3  
Old 01-25-2010
i do not know how to filter the txt-file Smilie

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 Smilie

i found a interesting blogpost.

Code:
apt-get install curlftpfs

Code:
#!/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:

Code:
# 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" ? :-)

edit soon
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Remove files older than 2 days.

Hi All, I am new to the scripting and using solaris 10 OS. Please suggest me from the below script which modifications need to be done to delete the files more that 2days older. Current script is deleting existing file. # Remove old explorer runs if needed DIR=`dirname ${EXP_TARGET}` if ... (2 Replies)
Discussion started by: Navkreddy
2 Replies

2. UNIX for Dummies Questions & Answers

Files older than 50 days

Hi All, OS :- HP-UX wm5qa B.11.23 U ia64 1119805695 unlimited-user license I need to search files older than 50 days. I've used following command in order to search desired files, I also discoverd, it's showing today's files as well. Do you have any clue with this ? wmqa1> find .... (4 Replies)
Discussion started by: alok.behria
4 Replies

3. UNIX for Advanced & Expert Users

find files older than 30 days old

Hello, I have a script which finds files in a directory that are older than 30 days and remove them. The problem is that these files are too many and when i run this command: find * -mtime +30 | xargs rm I run this command inside the directory and it returns the error: /usr/bin/find:... (8 Replies)
Discussion started by: omonoiatis9
8 Replies

4. UNIX for Advanced & Expert Users

removing files older than n days

Hi, on AIX 6.1, is there any commande line to remove the files older than n days in a directory ? Thanks. (2 Replies)
Discussion started by: big123456
2 Replies

5. Shell Programming and Scripting

List the files which are older than 7 days

Hi Frnds, I have to list the files which are older than 7 days in the given directory. it should consider only the files and should not show subdirectories. Thanks, Raja (3 Replies)
Discussion started by: smr_rashmy
3 Replies

6. UNIX Desktop Questions & Answers

Find files older than 10 days

What command arguments I can use in unix to list files older than 10 days in my current directory, but I don't want to list the hidden files. find . -type f -mtime +15 -print will work but, it is listing all the hidden files., which I don't want. (4 Replies)
Discussion started by: Pouchie1
4 Replies

7. Solaris

Delete files older than 30 days

Hi all, I want to delete log files with extension .log which are older than 30 days. How to delete those files? Operating system -- Sun solaris 10 Your input is highly appreciated. Thanks in advance. Regards, Williams (2 Replies)
Discussion started by: William1482
2 Replies

8. Solaris

Copying files older then 2 days

Hi everyone :) I have a little question here, at my work, we have a system running Solaris 10 - with an attached EMC SAN, the SAN is running out of space, and we are moveing the data to a new EVA SAN. The problem here is, that there are over 35.000.000 files on the system, and constantly 30... (4 Replies)
Discussion started by: Skovsen
4 Replies

9. UNIX for Dummies Questions & Answers

Delete files older than 30 days

This is driving me crazy. How can I delete files in a specifc directory that are over 30 days old? Thanks in advance. (3 Replies)
Discussion started by: tlphillips
3 Replies

10. UNIX for Dummies Questions & Answers

delete files older than 7 days

can anyone tell me how I would write a script in ksh on AIX that will delete files in a directory older than 7 days? (1 Reply)
Discussion started by: lesstjm
1 Replies
Login or Register to Ask a Question