CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

Home: Perl Programming Help: Intermediate: Re: [Laurent_R] collect log files remotely and store as 1 file: Edit Log


Nov 5, 2012, 4:44 AM

Views: 6855
Re: [Laurent_R] collect log files remotely and store as 1 file

Hi Laurent,

Sorry, let me explain a bit further, I need to write a script that collects files from 4 different machines and store them as 1, to get the data i connect to each server a store the names of the files into an array.

use POSIX 'strftime'; 
my $date = strftime("%Y%m%d", localtime(time - 86400));

@sys1list = system ("/usr/bin/ssh admin\@sys1 '/bin/ls -1 /$main_dir/event_log_$date??????.audit'");

Then i connect again and collect all the files in the array which works

But i cant get the contents of the files into 1 file, using the code below i just get the elements of the array Unsure

foreach (@sys1list){ 
$_ =~ s/\/\//\//g;
print " LINE = $_\n";
$dstfile=basename $_;
system (`/usr/bin/scp admin\@sys1:'$srcfile' /home/sys1/data/'$dstname'`);
system (`/bin/cat /home/sys1/data/'$srcfile' >> /home/sys1/data/log_$date`); // doesnt work
/// how can i get the data from the files instead of the array names ??

Once I've collected the data from all 4 machines i would like to cat all of these files into 1 file

I've tried using glob but couldn't get it to work. I've managed to collect the data but am struggling to get these files into 1. I also don't like the idea of connecting twice, any suggestions?

Many thanks for your help!


(This post was edited by jeffersno1 on Nov 5, 2012, 5:08 AM)

Edit Log:
Post edited by jeffersno1 (Novice) on Nov 5, 2012, 5:08 AM

Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives