<div dir="auto">Looks good to me. Did it work? I know that later file access time is not always recorded on the hard drive, but does inotify still get access notifications?<div dir="auto"><div dir="auto"><br></div><div dir="auto">As an aside, any reason you're not using the Perl built-on "rename" instead of move() from File::Copy?</div><div dir="auto"><br></div><div dir="auto">David</div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sat, Nov 25, 2023, 11:58 AM Richard Reina <<a href="mailto:richard@rushlogistics.com">richard@rushlogistics.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div>
<div style="color:rgb(0,0,0)"><font face="Arial"><span style="font-size:12pt">As it turn out </span></font><a href="https://metacpan.org/pod/Linux::Inotify2" style="font-family:Menlo,Monaco,Consolas,"Liberation Mono","Bitstream Vera Sans Mono",Courier,"Courier New",monospace;font-size:14px;white-space:pre-wrap;box-sizing:content-box!important;background:none!important;color:black!important;border-radius:0px!important;border:0px!important;float:none!important;height:auto!important;line-height:normal!important;margin:0px!important;outline:0px!important;overflow:visible!important;padding:0px!important;vertical-align:baseline!important;width:auto!important;min-height:auto!important" target="_blank" rel="noreferrer">Linux::Inotify2</a> <span>can get triggered by when a file is accessed. So here is what I came up with to detect when the file has been uploaded (accessed ) and then move it.<br>
<br>
use strict;<br>
use File::Copy;<br>
<br>
#waits for a waiting cvs file to be accessed and then moves it to old_cvs/ directory<br>
use Linux::Inotify2;<br>
my $inotify = new Linux::Inotify2 or die $!;<br>
my $dir ='/home/richard/cvs_ready/';<br>
<br>
$inotify->watch($dir, IN_ACCESS) or die "No such dir: $dir: $!\n";<br>
<br>
while () {<br>
<br>
my @events = $inotify->read;<br>
<br>
unless (@events > 0){<br>
print "read error: $!";<br>
last ;<br>
}<br>
<br>
my $i = 0;<br>
foreach my $event (@events) {<br>
<br>
$i++;<br>
if (substr($event->fullname, -1) ne '/') { # they accessed an actual file, not just an 'ls' on the directory<br>
<br>
print $event->fullname . " was modified\n" if $event->IN_ACCESS;<br>
sleep 60;<br>
print $event->fullname . " to /home/richard/old_cvs/\n";<br>
move($event->fullname, "/home/richard/old_cvs/") or die "move failed: $!"; # move the file<br>
<br>
}<br>
}<br>
<br>
} # end of while</span><br>
<br>
<br>
<br>
<span>On Thu, 23 Nov 2023 11:51:41 -0600, Richard Reina <<a href="mailto:richard@rushlogistics.com" target="_blank" rel="noreferrer">richard@rushlogistics.com</a>> wrote:</span><br>
<br>
<div dir="ltr"><span>Happy Thanksgiving All, </span><br>
<br>
<span>With the proliferation of bank fraud. I am now required by my bank to upload a CVS file with all of my recent checks so that they can validate checks being presented to my account. I am automating this process, but one step that I am not able to complete is for my perl script to know once a file have been uploaded so that it can move to an indicated directory. I have used </span><a href="https://metacpan.org/pod/Linux::Inotify2" style="font-family:Menlo,Monaco,Consolas,"Liberation Mono","Bitstream Vera Sans Mono",Courier,"Courier New",monospace;font-size:14px;white-space:pre-wrap;box-sizing:content-box!important;background:none!important;color:black!important;border-radius:0px!important;border:0px!important;float:none!important;height:auto!important;line-height:normal!important;margin:0px!important;outline:0px!important;overflow:visible!important;padding:0px!important;vertical-align:baseline!important;width:auto!important;min-height:auto!important" target="_blank" rel="noreferrer">Linux::Inotify2</a><span style="font-family:Menlo,Monaco,Consolas,"Liberation Mono","Bitstream Vera Sans Mono",Courier,"Courier New",monospace;font-size:14px;white-space:pre-wrap;background-color:rgb(245,245,245)">; </span><span> </span><span>but I don’t believe it will notify if a file is simply uploaded. Does anyone know </span><span>of a way that a file could be slightly modified once it’s selected via websites API for upload so that my Perl script will know to move it to a different directory?</span></div>
_______________________________________________<br>
Chicago-talk mailing list<br>
<a href="mailto:Chicago-talk@pm.org" target="_blank" rel="noreferrer">Chicago-talk@pm.org</a><br>
<a href="https://mail.pm.org/mailman/listinfo/chicago-talk" target="_blank" rel="noreferrer">https://mail.pm.org/mailman/listinfo/chicago-talk</a>
</div>
</div>_______________________________________________<br>
Chicago-talk mailing list<br>
<a href="mailto:Chicago-talk@pm.org" target="_blank" rel="noreferrer">Chicago-talk@pm.org</a><br>
<a href="https://mail.pm.org/mailman/listinfo/chicago-talk" rel="noreferrer noreferrer" target="_blank">https://mail.pm.org/mailman/listinfo/chicago-talk</a><br>
</blockquote></div>