[sf-perl] (no subject)

yary not.com at gmail.com
Fri Aug 6 10:11:44 PDT 2010


Waiting for a report to run at work, will try to help you out a bit-

you can simplify your script a little. I'm going to type without
running & checking, so there may be a few errors in here- read it,
understand what it's doing, try it out...

#!/usr/local/bin/perl -w

use Sys::Syslog;

# Set up a regular expression to match July 10-15
my $dates_rx='07-1[0-5]-2010';

my %files=> {
subetotal_pccs  => {pattern =>'/usr/reports/subetotal/SubEtotal_*.CSV',
remote  => '/pccsdata/Reports/Eusage/'},

lnwih2s_pccs    => {pattern=>'/usr/reports/lnwih2s/lnwih2s_*.CSV',
remote=>'/pccsdata/Reports/LNWI'},

dailylog_pccs   =>{pattern=>'/usr/reports/dailylog/DailyLog_*.CSV',
remote    =>'/pccs/tahar'}

n16_pccs        =>{pattern=>'/usr/jpc/reports/n16/n16_08-06-2010.CSV',
remote         =>'/pccsdata/Reports/hydraulics'}
};

$command = '/usr/develop/apps/ftp_report.pl';

$program = $0;
$logopt = 'cons, pid';
$facility = 'HSR';

 # set up the syslog messages.
 openlog($program, $logopt, $facility);

 # Loop through all file categories.
while (my ($category, $details)=each %files) {
  for my $file (< $$details{pattern} >) {
    next unless $file =~ /$dates_rx/o;
   @args = ($command, $file, $details->{remote});
    # Run command, and log if failure
    if (! system (@args) == 0 ) {
      syslog('LOG_ALERT|LOG_LOCAL0', 'Failed to send %s to MIS', $file);
   die 'Failed to send ',$file,' to MIS, stopped';
 }

END {
  # Always calls closelog, even on a "die"
 closelog();
}

-y


More information about the SanFrancisco-pm mailing list