Afficher un message
Vieux 11/09/2007, 22h15   #5
William James
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Script to compare dates and notify

On Sep 11, 2:12 pm, littleh...@gmail.com wrote:
> I am trying to put together a script to compare the dates of a file
> and send out an email notification if the date on the file is beyond
> 30 calendar days. However, I am having a bit of trouble. The file
> format is <filename>_%m%d%y. So for example
> foobar1_090207
> foorbar2_090307
> foorbar3_091507
> I parse the file so I am just left with the date extension from
> there I want to be notified of any file over the 30 day mark.
>
> I tried using expr and setting up a variable for the 30 days but its
> not working. Any would be appreciated. Thanks.


#!ruby
require 'date'
Dir['foobar*'].each{|f|
f =~ /(\d\d)(\d\d)(\d\d)$/
date = Date.parse( "20"+[$3,$1,$2].join("-") )
puts f if (Date.today - date) > 30
}

  Réponse avec citation
 
Page generated in 0,04437 seconds with 9 queries