Ignoring the fact that the line inside the while loop is not valid perl, if it were in a shell script, I submit that it would be a contender for the Useless cat award since
cat /mnt/scripts/lagtime/tmp/input.txt |awk '{printf "%1.50s\t%0.60s\t +%0.45s\t %0.45s\n", $1, $2, $3, $4}' | sh /mnt/scripts/lagtime/calcul +ate_lag.sh > /tmp/snapvault_status.out.out;
is identical to
awk '{printf "%1.50s\t%0.60s\t%0.45s\t %0.45s\n", $1, $2, $3, $4}' /mn +t/scripts/lagtime/tmp/input.txt | sh /mnt/scripts/lagtime/calculate_l +ag.sh > /tmp/snapvault_status.out.out;
Moreover, elsewhere, you claim that Awk is needed to put the columns in the right place... - a palpably untrue claim since you're simply using awk to strip out and re-format the first 4 columns, leaving the ordering untouched.

The problem is that the last output file is empty - this shouldn't come as a huge surprise if the last of the input lines causes an empty line to be written to the output - via the /mnt/scripts/lagtime/calculate_lag.sh script - since, within the loop, the output file is rewritten, c/w being appended to, each time.

In the light of this, I think I'd be tempted to

  1. Modify /mnt/scripts/lagtime/calculate_lag.sh to take a single line as an argument
  2. Coalesce the ssh invocations with the awk command
  3. Finally, to re-write it [the snippet] something along the following lines i.e. untested:
use warnings; use strict; use autodie; my @HOSTS = qw/datab01 datab02 datab03/; my $IN_FILE = q(/mnt/scripts/lagtime/tmp/input.txt); my $OUT_FILE = q(/tmp/snapvault_status.out.out); open IN_FILE, qq/>$IN_FILE/; foreach my $host (@HOSTS) { foreach (`ssh $host snapvault status | tail -n +3`) { local @_ = split; # Avoid warnings printf IN_FILE "%1.50s\t%0.60s\t%0.45s\t %0.45s\n", $_[0], $_[ +1], $_[2], $_[3]; } } close IN_FILE; open IN_FILE, qq/<$IN_FILE/; open OUT_FILE, qq/>$OUT_FILE/; while (<IN_FILE>) { print OUT_FILE `sh /mnt/scripts/lagtime/calculate_ +lag.sh $_` } close IN_FILE; close OUT_FILE;
A user level that continues to overstate my experience :-))

In reply to Re: Script to manipulate data is not giving me any output by Bloodnok
in thread Script to manipulate data is not giving me any output by ebi

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.