KevinBr:

No, I don't mind. Here's a stripped down version of the report processor:

#!/usr/bin/perl -w use strict; use warnings; use myUtils; ### # CONFIG ### my %Apps = ( CSV_Reports => { cmdline=>'CSV_reports.pl', ext=>'.csv', inbound=>'/Rpts', outbound=>'/Rpts/CSV' }, Excel_Reports => { cmdline=>'NME_report.pl', ext=>'.nme', inbound=>'/Rpts', outbound=>'/Rpts/XL', }, ); my $DozeTime = 5; #5 * 60; # 5 min my $DieFile = '/var/log/report_processor.halt'; ### # CODE ### open my $LOG, '>>', '/var/log/report_processor.log' or die $!; print $LOG join("\n", box_fixed(80, 'Reports Log', 'Started at: ' . myUtils::timestamp() ), ), "\n\n"; while (! -e $DieFile) { for my $RName (keys %Apps) { chdir $Apps{$RName}{inbound}; my @files = map { s/\s+$//; $_ } # and chomp the names grep { /$Apps{$RName}{ext}$/ } # files for this repo +rt qx( ls -1 --file-type ); # check inbound dir f +or for my $FName (@files) { print $LOG myUtils::timestamp() . ": processing $RName: infil +e $FName\n"; my $curtime = time; system($Apps{$RName}{cmdline}, $FName); $curtime = time - $curtime; print $LOG "\t$curtime secs.\n\n"; print "mv $FName $Apps{$RName}{outbound}/$FName"; rename($FName, "$Apps{$RName}{outbound}/$FName") or die $!; } } sleep $DozeTime; } if (-e $DieFile) { print $LOG "Normal halt at " . myUtils::timestamp() . "\n\n"; unlink $DieFile; } else { print $LOG "*UNEXPECTED HALT: " . myUtils::timestamp() . "\n\n"; }

The basic shell for something that would generate the data file would be like:

#!/usr/bin/perl -w use strict; use warnings; my $FName = '/Rpts/geezer.csv'; open my $OF, '>', "$FName.work" or die $!; print $OF <<JUNK; A bunch of junk to generate a report. JUNK close $OF; rename "$FName.work", $FName;

...roboticus


In reply to Re^4: read directory, fork processes by roboticus
in thread read directory, fork processes by KevinBr

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.