You don't have any error checking so that would probably be better written as:

#!/usr/bin/perl use warnings; use strict; use POSIX qw(strftime); use File::Basename; my $in_dir = '/home/data'; my $out_dir = '/var/www/html/rwa_test/input'; my $zip_dir = '/home/data/archive'; my $kpva = strftime '%Y%m%d', localtime; my $wait = 30; { for my $ifn ( sort { -M $b <=> -M $a } <$in_dir/*.P.M> ) { print "$ifn\n"; $ifn = basename $ifn; print "$ifn\n"; { open my $IN, '-|', 'gzip', '-c', "$in_dir/$ifn" or die "Ca +nnot open pipe from gzip: $!"; open my $ZIP, '>:raw', "$zip_dir/$ifn.$kpva.gz" or die "Ca +nnot open '$zip_dir/$ifn.$kpva.gz' $!"; local $/ = \4096; print $ZIP $_ while <$IN>; close $IN or warn $! ? "Error closing gzip pipe: $!" : "Exit status $? from gzip"; } open my $IF, '<', "$in_dir/$ifn" or die "Cannot open '$in_dir/ +$ifn' $!"; open my $OF, '>', "$out_dir/$ifn.$kpva" or die "Cannot open '$ +out_dir/$ifn.$kpva' $!"; while ( <$IF> ) { last if /^-{19}/; tr/,\t/.;/; print $OF $_; } my $cmd = qq[dbisqlc -c "uid=.....;pwd=.....;eng=......;dbn=.. +.... " -q call ......Fun_LoadAllFiles( '$out_dir/$ifn.$kpva', '$ifn.$ +kpva')]; print "$cmd\n"; 0 == system $cmd or die "system $cmd failed: $?"; rename "$in_dir/$ifn", "$in_dir/$ifn.done" or die "Cannot rena +me '$in_dir/$ifn' $!"; } sleep $wait and redo; }

In reply to Re: unable execute $cmd by jwkrahn
in thread unable execute $cmd by tannx

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.