<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto">Check the return code of the action <div><br></div><div><br id="lineBreakAtBeginningOfSignature"><div dir="ltr"><span style="background-color: rgba(255, 255, 255, 0);">(Sent from iPhone, so please accept my apologies in advance for any spelling or grammatical errors.)</span></div><div dir="ltr"><br><blockquote type="cite">On Nov 25, 2023, at 10:58 AM, Richard Reina <richard@rushlogistics.com> wrote:<br><br></blockquote></div><blockquote type="cite"><div dir="ltr">
<title></title>
<div class="userStyles" 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; scroll-margin-top: 60px; white-space: pre; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); text-size-adjust: 100%; box-sizing: content-box !important; background: none !important; color: black !important; border-radius: 0px !important; border: 0px !important; inset: auto !important; float: none !important; height: auto !important; line-height: normal !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; vertical-align: baseline !important; width: auto !important; min-height: auto !important;">Linux::Inotify2</a> <span style="-webkit-text-size-adjust: auto;">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>
<footer class="signatureContainer" style="font-family: Arial; font-size: 12pt; display: inline;"> </footer>
<footer class="replyforwardcontainer" style="font-family: Arial; font-size: 12pt;"><br>
<br>
<span>On Thu, 23 Nov 2023 11:51:41 -0600, Richard Reina <richard@rushlogistics.com> wrote:</span><br>
<br>
<div dir="ltr"><span style="-webkit-text-size-adjust: auto;">Happy Thanksgiving All, </span><br style="-webkit-text-size-adjust: auto;">
<br style="-webkit-text-size-adjust: auto;">
<span style="-webkit-text-size-adjust: auto;">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="scroll-margin-top: 60px; font-family: Menlo, Monaco, Consolas, "Liberation Mono", "Bitstream Vera Sans Mono", Courier, "Courier New", monospace; font-size: 14px; white-space: pre; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); -webkit-text-size-adjust: 100%; box-sizing: content-box !important; background: none !important; color: black !important; border-radius: 0px !important; border: 0px !important; inset: auto !important; float: none !important; height: auto !important; line-height: normal !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; vertical-align: baseline !important; width: auto !important; min-height: auto !important;">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; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); -webkit-text-size-adjust: 100%; background-color: rgb(245, 245, 245);">; </span><span style="-webkit-text-size-adjust: auto;"> </span><span style="-webkit-text-size-adjust: auto;">but I don’t believe it will notify if a file is simply uploaded. Does anyone know </span><span style="-webkit-text-size-adjust: auto;">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>
Chicago-talk@pm.org<br>
https://mail.pm.org/mailman/listinfo/chicago-talk</footer>
</div>
<span>_______________________________________________</span><br><span>Chicago-talk mailing list</span><br><span>Chicago-talk@pm.org</span><br><span>https://mail.pm.org/mailman/listinfo/chicago-talk</span><br></div></blockquote></div></body></html>