Sponsored Content
Full Discussion: ftp only older files
Top Forums Shell Programming and Scripting ftp only older files Post 302320955 by ghostdog74 on Friday 29th of May 2009 11:48:05 AM
Old 05-29-2009
if you have Python,
Code:
#!/usr/bin/env python
import ftplib,datetime,time
today = datetime.date.today()

server="localhost"
user="anonymous"
password="test@hotmail.com"
filelist=[]
months={
 "Jan":"01","Feb":"02","Mar":"03","Apr":"04","May":"05", 
 "Jun":"06","Jul":"07","Aug":"08","Sep":"09","Oct":"10",
 "Nov":"11","Dec":"12"
}

def download(ftp, filename):    
    '''function to download file'''
    ftp.retrbinary("RETR " + filename, open(filename,"wb").write)
    
try:
    ftp = ftplib.FTP()
    ftp.connect(server,21)    
    ftp.login(user,password)
except Exception,e:
    print e
else:    
    ftp.cwd("incoming")    
    ftp.retrlines('LIST',filelist.append)    
    for items in filelist:
        items=items.split()
        mth,day,yr = items[5:8]        
        if ":" in yr:
            yr=today.year        
        thedate = datetime.date(int(yr),int(months[mth]),int(day))
        result = today - thedate 
        if  result.days > 20:
            filename =''.join(items[8:])
            print "downloading .. " , filename
            download(ftp,filename)

 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

rm files older than ...

Hello, How can I remove files older than yesterday or the day before or a given day ... Thank you in advance (2 Replies)
Discussion started by: annemar
2 Replies

2. UNIX for Dummies Questions & Answers

Reg: delete older files from ftp

Hi, I want to delete older files from ftp server. (files which are more than 5 days old). Please advice Thanks , sam (3 Replies)
Discussion started by: sam99
3 Replies

3. Shell Programming and Scripting

rm files older then 2 seconds?

Hello, I've got a script to delete 0 byte files, but I need it to work only for files that have been created at least 2 seconds ago (Are two seconds old). I'm not sure what's the best way of doing this, I've had a look at the stat command too but well.. for file in `ls -l | grep ^- |... (7 Replies)
Discussion started by: TehOne
7 Replies

4. Shell Programming and Scripting

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 Replies)
Discussion started by: tetex
2 Replies

5. 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

6. Shell Programming and Scripting

how to delete the older files other than the recently added 5 files

Number of files will get created in a folder automatically daily.. so i hav to delete the older files other than the recently added 5 files.. Could u help me through this..?? (5 Replies)
Discussion started by: shaal89
5 Replies

7. Shell Programming and Scripting

Delete files older than 1 year through FTP

Hi All, I want to login to a remote server using FTP command and then check for files older than 1 year and delete those files. Please let me know how can i achieve this using Unix Commands. Thanks in Advance, (10 Replies)
Discussion started by: HemaV
10 Replies

8. Shell Programming and Scripting

How to move the older than 30 file to another ftp server

Hi All I need to move the older than 30 days file to another ftp server. I have source structure like this Files folder Folder1 Folder2 Folder3 I need to create same Target structure and I need to move the older than 30 day file to another ftp server, can you please suggest me how I develop... (1 Reply)
Discussion started by: murari83.ds
1 Replies

9. UNIX for Advanced & Expert Users

Help with get/mget from FTP server with files older than 10 minutes

Hi! I am new to unix and this forum as well.. Can someone please help me : I want to "get/mget" files which are older than 10 minutes from a remote FTP server like "ftp.com". After getting the files to local unix server say "Prod.com" , i need to delete only those files from ftp.com which... (4 Replies)
Discussion started by: SravsJaya
4 Replies

10. Shell Programming and Scripting

How to create zip/gz/tar files for if the files are older than particular days in UNIX or Linux?

I need a script file for backup (zip or tar or gz) of old log files in our unix server (causing the space problem). Could you please help me to create the zip or gz files for each log files in current directory and sub-directories also? I found one command which is to create gz file for the... (4 Replies)
Discussion started by: Mallikgm
4 Replies
roarinterconnect(1)				      System User's Manual: roarinterconnect				       roarinterconnect(1)

NAME
roarinterconnect - interconnect two audio servers SYNOPSIS
roarinterconnect [OPTIONS]... DESCRIPTION
This program can interconnect two audio servers bi- (default) or uni-directional. OPTIONS
--server SERVER Set server hostname --remote SERVER Set remote server --type TYPE Set type of remote server --rate RATE Set sample rate --bits BITS Set bits per sample --chans CHANNELS Set number of channels --codec CODEC Set the codec --help Show this help --verbose -v Be verbose POSSIBLE TYPES
roar RoarAudio Server esd EsounD Server simple PulseAudio simple protocol oss Open Sound System (OSS) device bidir Connect bidirectional filter Use local server as filter for remote server transmit Transmit data from local server to remote server receive Receive data from remote server SEE ALSO
roartips(7), libroar(7), RoarAudio(7). HISTORY
For history information see RoarAudio(7). RoarAudio January 2010 roarinterconnect(1)
All times are GMT -4. The time now is 03:21 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy