Hi all,
I am new to perl and have created the following script which should create an output file ( input.txt ) which I then run against a sh script which creates an ouput which I re direct to another file caled snapvault_status.out.
The problem is that the last output file is empty but if I run the command on the command line I do get a filed file.
I am sure my code is not great but I just started with perl :-)
Any advice is appreciated.
sub read_data
{
system "ssh datab01 snapvault status | tail -n +3 > /mnt/scri
+pts/lagtime/tmp/input.txt";
system "ssh datab02 snapvault status | tail -n +3 >> /mnt/scri
+pts/lagtime/tmp/input.txt";
system "ssh datab03 snapvault status | tail -n +3 >> /mnt/scri
+pts/lagtime/tmp/input.txt";
print "Data is uitgelezen.\n";
}
sub create_correct_output
{
open(MYINPUTFILE, "</mnt/scripts/lagtime/tmp/input.txt");
while(<MYINPUTFILE>)
{
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/script
+s/lagtime/calculate_lag.sh > /tmp/snapvault_status.out.out;
}
print "data has been put in the right format.\n";
}
Thanks in advance.
Eric
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.