Welcome to the most active Linux Forum on the web.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 08-30-2006, 06:09 PM   #1
LQ Newbie
Registered: Aug 2006
Posts: 2

Rep: Reputation: 0
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!


Last edited by kender; 08-30-2006 at 09:57 PM.
Old 08-31-2006, 06:37 PM   #2
LQ 5k Club
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,397
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
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.

--- rod.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
i want to know the command which show the date of creation of file abhi_singh4 Red Hat 6 09-16-2011 12:02 AM
File Creation Date in linux jayukanna General 5 08-21-2006 07:08 AM
ls -al file creation date blackzone Linux - Newbie 2 08-23-2004 01:31 AM
php read file creation, modified date problem antony_csf Programming 3 08-18-2004 06:46 AM
creation date of file using the 'ls' command robt Linux - Newbie 1 03-27-2003 12:34 AM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:38 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration