in reply to File Search
use strict; use warnings; use File::Find; use Mail::Send; my $curtime = time(); find(\&wanted, qw(/home/arjen/test)); sub wanted { # Warning: the ctime field is not really the creation time! # See perlport (File and Filesystems) return if (($curtime - (stat($File::Find::dir))[10])) > 900; return if $_ !~ /\.out$/; open(FILE, "<$_") or die "Cannot open $_: $!\n"; while (my $line = <FILE>) { last if $line =~ /error/; } close(FILE); my $msg = Mail::Send->new(Subject => "Error found!", To => "operator\@datacenter"); my $fh = $msg->open(); print $fh "We found an error in $_!\n"; $fh->close(); print "Mail sent\n"; }
Arjen
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: File Search
by mikevanhoff (Acolyte) on Oct 27, 2003 at 17:25 UTC | |
by Aragorn (Curate) on Oct 27, 2003 at 19:35 UTC | |
by mikevanhoff (Acolyte) on Oct 27, 2003 at 20:48 UTC |