In my shell script I have to parse three files which are on the remote server and retrieve the date from the files. I wrote this command to retrieve the 3 files but how would I parse the files? Should I scp them to my local machine or should I just parse the files on the remote machines/
This is the command to retreive the files
ssh user\@qsapp05 "cd /d1/di//log; ls -ltr | tail -3 | cut -d' ' -f16"
This is my script for parsing the files:
my %Months = (Jan => '01', Feb => '02', Mar => '03',
Apr => '04', May => '05', Jun => '06',
Jul => '07', Aug => '08', Sep => '09',
Oct => '10', Nov => '11', Dec => '12');
open(OUT, ">>$home/Monitoring/test.t
xt") or die "test.txt: $!\n";
foreach my $file (@listOfFiles){
print "File: $file\n";
my $name = $1 if (split(/_/,$file))[1] =~ /AS(.*)NDR/;
$nameUpdate = 'Positions' if $name =~ /position/;
$nameUpdate = 'Balances' if $name =~ /balance/;
$nameUpdate = 'Transactions' if $name =~ /Tranx/;
warn "Could not open $file: $!\n",next unless open (FH, "<$file");
my @times = ();
while (<FH>){
if(/(\w+)\s+(\d+)\s+(\S+)\
s+EST\s+(\
d+)/){
push @times, $3;
push @dates, "$Months{$1}/$2/$4";
}
}
I need to merge them please advise.
Start Free Trial