Date of file creation on the remote FTP host
I’m new to shell scripting. (That was a unique and creative opening sentence, wasn’t it?) I need to write an automated FTP retriever that would download only those files from a remote host, that are older than X days. At this point I can use a ftp>dir command to get the list of all the files in the directory on the remote host (including the ones that are not older than X days) into a file on the local host. So, finally, here’s are the questions:
1. Is it possible to supply the arguments for the ftp>dir command so that it would return only the files older than X days?
2. What’s the best approach to parsing a file that contains a list of files from the remote host? I can iterate through the list with a for loop and parse every line. However, my gut feeling is that there should be a better way of doing this.
Please post any ideas that pop up, even if it's an incomplete solution!
I believe it is an implementation detail regarding what, if any, time/date information is provided by a FTP server. Having said that, I would use a tool such as perl to parse something as ugly as file time/date stamps. If the server returns things in the 'ls' format, you cannot even rely on a consistant format, depending on how old the file is. And, since you are using perl anyway, :) why not use a perl module just made for things like retrieving files from an FTP server, like Net::FTP?
I don't see any way around parsing each file reference in the returned directory listing. I don't think there is any standard way of limiting the the scope of listed files by time/date.
|All times are GMT -5. The time now is 04:34 AM.|