[Tutor] Ftp files
bizag007 at yahoo.com
Tue Dec 19 16:11:45 CET 2006
I have just started to learn Python and think it is a superb language. I am faced with an issue that I would like some help with. I need to fetch files on a daliy basis from a unix machine. I would like to run a batch command for this. I would also like to automate this task. The files are stored on the unix box; are hourly files with date and time as the file name. What I would like to do is log in to the relevant directory and fetch the files for that day. I have managed to log in to the ftp site and navigate to the directory where the files are. I have also used the following command to look for a particular day:
dateMatch = str(localtime())+str(localtime())+str(localtime())
This will give me the date portion of the string to search in the file name using:
I am now stuck on how to use the
files = listdir(pathName)
to get a list of the files and by using the following code:
for i in files:
matchFile = search(dateMatch,i)
get the file
What I would like to know is how to get the file using ftplib functions. Your expert advice would be very helpful. Please feel free to suggest some code and an explanation...
I need help on the following:
-How to get a function to return a list of the files on the directory
-Using this list I should be able to use the for loop to match the date case and
- fetch the files using the get command. How to use the get command to fetch the files in the list prevously where the match was found and store this in my local directory?
- Also how to run this python file daily automatically?
Looking forward to you responses..
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Tutor