You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by dangerop <na...@hotmail.com> on 2010/10/09 01:34:28 UTC

avoid ftp get if files are too old?

Hi,

I've got a situation where we run a weekly process to download files off an
ftp site once a week.  I've got an Ant build file which will connect to the
server and download the files, but I'd like to avoid downloading them if the
files are from the previous week.  I was thinking of getting the file
timestamp and comparing it to e.g. (now - 10 days) but I haven't had much
luck finding this in the documentation.

The closest I've gotten is this, which downloads the files, uses tstamp to
set a datestamp offset from today, touches a file with that datestamp, then
uses uptodate to see if the file from the ftp site is newer:

1. ftp action="get" preservelastmodified="true" (file would be "weekly.zip")
2. tstamp to set property cutoff, with pattern="MM/dd/yyyy hh:mm aa"
offset="-10" unit="day"
3. touch file="${dir.data}/cutoff-date" datetime="${cutoff}"/>
4. uptodate property="is.newer" srcfile="${dir.data}/cutoff-date"
targetfile="${dir.data}/weekly.zip"
5. antcall another target with the "if" attribute set to the is.newer
property.

This works, but one of the files is several gigabytes large and so I'd like
to be able to just check the timestamps before transferring it.  Any ideas?

Thanks,
KaJun

-- 
View this message in context: http://ant.1045680.n5.nabble.com/avoid-ftp-get-if-files-are-too-old-tp3205466p3205466.html
Sent from the Ant - Users mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Re: avoid ftp get if files are too old?

Posted by dangerop <na...@hotmail.com>.
Hi David,

I think the "depends" attribute will work.  I saw it before but didn't try
it extensively because I can't rely on the files remaining there from the
previous week, but I just realized I could do the same thing as I currently
have and touch a file with the same name and use an old datestamp.

Thanks!
KaJun
-- 
View this message in context: http://ant.1045680.n5.nabble.com/avoid-ftp-get-if-files-are-too-old-tp3205466p3207865.html
Sent from the Ant - Users mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Re: avoid ftp get if files are too old?

Posted by David Weintraub <qa...@gmail.com>.
Have you looked at the "depends" parameter? The "depends" property
won't download a file if a file with the same name is already there,
and the file on the local machine has a newer timestamp than the file
on the remote machine. By default, "depends is set to "no" which means
it will download all the files even if you already have that file. Try
setting it to "yes" and see if that helps.

If the "depends" parameter doesn't work for you, a possibility is to
use the <sshexec> task to execute a command in your FTP server get a
listing of the files that are less than 10 days old. On Unix, you
could use the <sshexec> task to run a "find" command using the "mtime"
parameter:

    $ find $directory -type f -mtime +10

You can then save the output to a file or a property and use that to
generate the files you want.

The other possibility is to use the <exec> task to actually run the
Unix ftp command itself. You can use a NETRC file (which can be passed
to the ftp command to run the commands you want (login, cd to the
correct file, and then run an "ls -l"). You'll probably have to then
parse this output with a shell script to get the information you need.

-- 
David Weintraub
qazwart@gmail.com

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


AW: avoid ftp get if files are too old?

Posted by Ja...@rzf.fin-nrw.de.
<ftp><fileset><modified>

This will upload only the 'modified' files (independ of the date).


Jan 

>-----Ursprüngliche Nachricht-----
>Von: dangerop [mailto:nabbleOp@hotmail.com] 
>Gesendet: Samstag, 9. Oktober 2010 01:34
>An: user@ant.apache.org
>Betreff: avoid ftp get if files are too old?
>
>
>Hi,
>
>I've got a situation where we run a weekly process to download 
>files off an
>ftp site once a week.  I've got an Ant build file which will 
>connect to the
>server and download the files, but I'd like to avoid 
>downloading them if the
>files are from the previous week.  I was thinking of getting the file
>timestamp and comparing it to e.g. (now - 10 days) but I 
>haven't had much
>luck finding this in the documentation.
>
>The closest I've gotten is this, which downloads the files, 
>uses tstamp to
>set a datestamp offset from today, touches a file with that 
>datestamp, then
>uses uptodate to see if the file from the ftp site is newer:
>
>1. ftp action="get" preservelastmodified="true" (file would be 
>"weekly.zip")
>2. tstamp to set property cutoff, with pattern="MM/dd/yyyy hh:mm aa"
>offset="-10" unit="day"
>3. touch file="${dir.data}/cutoff-date" datetime="${cutoff}"/>
>4. uptodate property="is.newer" srcfile="${dir.data}/cutoff-date"
>targetfile="${dir.data}/weekly.zip"
>5. antcall another target with the "if" attribute set to the is.newer
>property.
>
>This works, but one of the files is several gigabytes large 
>and so I'd like
>to be able to just check the timestamps before transferring 
>it.  Any ideas?
>
>Thanks,
>KaJun
>
>-- 
>View this message in context: 
>http://ant.1045680.n5.nabble.com/avoid-ftp-get-if-files-are-too
>-old-tp3205466p3205466.html
>Sent from the Ant - Users mailing list archive at Nabble.com.
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
>For additional commands, e-mail: user-help@ant.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org