My objective here is to: 1) Clean this script up
#!/usr/bin/perl use warnings; use strict; # THIS SCRIPT CONCATENATES DATA FOR 1 WEEK OF RELIANT TRUST DATA AND S +ENDS TO NDM # my $MT = 'my.email.com'; # Mail Alias used for sendin +g emails my $ASL = 'app-server'; my @BFL = qw( name1.log name2.log ); # START TIME AND DATE VARIABLES # my ( $mday, $mon, $year, $wday ) = ( localtime $^T - 3600 * 24 )[ 3 .. + 6 ]; # Saturday only exit 0 if $wday != 5; # # END TIME AND DATE VARIABLES for my $f ( @BFL ) { my $catfile = sprintf '%s.%d%02d%02d', $f, $year + 1900, $mon + 1, + $mday; open my $CAT, '>', $catfile or die "Cannot open '$catfile' $!"; for my $i ( 5 .. 8 ) { for my $dd ( reverse 1 .. 7 ) { # Number of days to go back + for process my ( $mday, $mon, $year ) = ( localtime $^T - $dd * 3600 * + 24 )[ 3 .. 5 ]; my $fileext = sprintf '%s.myservername%d.%d%02d%02d', $f, +$i, $year + 1900, $mon + 1, $mday; open my $IN, '<', "$fileext.$ASL$i" or warn "Cannot open ' +$fileext.$ASL$i' $!"; print $CAT while <$IN>; } } # the cat-ed file is produced: scp it my $filetoput = "/home/echxfr/$catfile"; my @cmd = ( '/usr/bin/scp', $catfile, "cduser\@ndm:$filetoput", ); my $rv = system @cmd; if ( $rv == -1 ) { print "Unable to execute scp: $!\n"; } elsif ( $rv & 127 ) { printf "scp to died with signal %d\n", $rv & 127; } elsif ( $rv >> 8 ) { printf "scp exited with error %d\n", $rv >> 8; } else { print "scp was successful\n"; } if ( -z $catfile ) { 0 == system '/bin/mailx', '-s', "ERROR: Reliant SCP Log file $ +catfile sent to ndm is empty", $MT or warn "system 'mailx' failed: $?"; } }

In reply to Re: Help with Concatenates script by jwkrahn
in thread Help with Concatenates script by wskibum

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.