my intention is to monitor for newly created files in a directory and the same directory is shared among many computers and below is the script for your reference and once i run the script which identifies the files which are created from the machine xyz (on which i am running notifier script)and it does not recognizes the files from machine abc! Is there anything i need to consider for monitoring newly created files under the given directory ?. irrespective of the machine from which the files are created.
Is there any way to track the file created on different machines using 'inotify2.pm' ?
use Linux::Inotify2;
my $inotify;
$inotify = new Linux::Inotify2 ;
my $dir="/home/vikas/";
opendir(DIR, $dir);
while(readdir DIR)
{
print "$dir/$_\n";
-d $_ and $inotify->watch($_,IN_CREATE, \&watch_new);
}
close DIR;
sub watch_new
{
my $e = shift;
my $name = $e->fullname;
print "File was created! $name\n";
}
while(1)
{
$inotify->poll;
}