azatoth has asked for the wisdom of the Perl Monks concerning the following question:
This is fine. I can cron this and have it check for files whenever. But what I would really like to do is put some sort of loop in the script, that checks say, every 10 minutes, for new files. I can tell it what exact file to look for, but need some kind of "Trigger" functionality to kick off the script...Anyone have any ideas / follow me at all?#!/usr/bin/perl -w use strict; use Net::FTP; use Getopt::Long; my %opt = (); GetOptions( \%opt, "usr=s", "pwd=s", ); chdir("/home/export/data/"); @files = reverse ( map { split (/\s+/))[8]; } `ls -lrt Open_ +Trade_Summary*`); foreach my $file (@files[0..3]) { check_age($files); } sub check_age{ my $file = shift; ( (if -M $file) < .5 ) { print "$file is current - ok to send\n"; send_file($file); } else { print "No current data available\n"; } sub send_file{ my $file = shift; my $ftp = Net::FTP->new("ntbox01.host.org"); $ftp->login($opt{usr}, $opt{pwd}); $ftp->cwd($remDir); $ftp->put($file); $ftp->exit; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Using Trigger Files
by tadman (Prior) on Jun 14, 2001 at 16:24 UTC | |
|
Re: Using Trigger Files
by Zaxo (Archbishop) on Jun 14, 2001 at 16:47 UTC | |
|
Re: Using Trigger Files
by wardk (Deacon) on Jun 14, 2001 at 17:40 UTC | |
by azatoth (Curate) on Jun 14, 2001 at 17:47 UTC | |
|
Re: Using Trigger Files
by arturo (Vicar) on Jun 14, 2001 at 17:02 UTC | |
|
Re: Using Trigger Files
by mattr (Curate) on Jun 14, 2001 at 18:02 UTC |