PerlDiscuss - Perl Newsgroups and mailing lists wrote:

Hi there,

Hello,


Can anyone recommend a good way to have a perl script that constantly
monitors for the creation of new files on UNIX and launches another
process?

Not sure if someone else recommended this but:


[untested code - for example only]
 #!/usr/bin/perl

 use strict;
 use warnings;

 while(1) {
   opendir DIRH, '/foo/bar' or die $!;
   my @curlst = <DIRH>;
   closedir(DIRH);
   if(grep /watch for me/, @curlst) {
       # launch other process here...
   }
   sleep(15);
 }

Then start it running like so:
./thisscript.pl &

Thanks!

np, HTH


Lee.M - JupiterHost.Net

Cheers,
Ben



-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>




Reply via email to