From: hadaq Date: Mon, 13 Feb 2012 15:14:39 +0000 (+0000) Subject: JAM: updated data2tape script from newer version in lxhadeb03/bin X-Git-Url: https://jspc29.x-matter.uni-frankfurt.de/git/?a=commitdiff_plain;h=9079ccbf5f1b091df68487b36778bad90e08638b;p=daqdata.git JAM: updated data2tape script from newer version in lxhadeb03/bin --- diff --git a/disks/daq_disks b/disks/daq_disks index 427eb15..2eeb2f3 100755 Binary files a/disks/daq_disks and b/disks/daq_disks differ diff --git a/disks/data2tape.pl b/disks/data2tape.pl index b7ebac2..e959c5d 100755 --- a/disks/data2tape.pl +++ b/disks/data2tape.pl @@ -15,13 +15,18 @@ my $opt_endDate; my @prefix_list = (); my @file_list; my $file_list_aref = \@file_list; +my $opt_file; my $opt_arch; +my $opt_dir = "hld"; GetOptions ('h|help' => \$opt_help, + 'f|file=s' => \$opt_file, 's|start=s' => \$opt_startDate, 'e|end=s' => \$opt_endDate, 'p|prefix=s' => \@prefix_list, - 'a|arch=s' => \$opt_arch); + 'a|arch=s' => \$opt_arch, + 'd|dir=s' => \$opt_dir + ); if( $opt_help ) { &help(); @@ -32,11 +37,12 @@ if(-1 == &checkArgs()){ exit(0); } -my $startSec = &date2sec($opt_startDate); -my $endSec = &date2sec($opt_endDate); - -&getFileList(); - +if(defined $opt_file){ + &getFileListFromFile(); +} +else{ + &getFileList(); +} &archive(); exit(0); @@ -59,12 +65,17 @@ Usage: [-s|--start ] : Beginning of time interval. [-t|--end ] : End of time interval. [-p|--prefix ] : Archive only these prefixes. + [-f|--file ] : Path to hld file list. [-a|--arch ] : Archiving is done only with this option enabled. + [-d|--dir ] : Path to the file in the archive. Examples: Archive all hld files with prefixes 'st' and 'be' from sept 4th, 2010 to the archive hadessep10raw: - date2tape.pl -p be -p st -s 2010-09-04_00:00:00 -e 2010-09-04_23:59:59 -a hadessep10raw + date2tape.pl -p be -p st -s 2010-09-04_00:00:00 -e 2010-09-04_23:59:59 -a hadessep10raw + + Archive all hld files from the list /home/hadaq/kgoebel.txt to archive "hadesuser/kgoebel/hld/": + date2tape.pl -a hadesuser -d kgoebel/hld -f /home/hadaq/kgoebel.txt EOF } @@ -73,14 +84,16 @@ sub checkArgs() { my $retval = 0; - unless( defined $opt_startDate ){ - print "Start date is not given!\n"; - $retval = -1; - } - - unless( defined $opt_endDate ){ - print "End date is not given!\n"; - $retval = -1; + unless( defined $opt_file ){ + unless( defined $opt_startDate ){ + print "Start date is not given!\n"; + $retval = -1; + } + + unless( defined $opt_endDate ){ + print "End date is not given!\n"; + $retval = -1; + } } return $retval; @@ -113,8 +126,26 @@ sub date2sec() return $sec_epoch; } +sub getFileListFromFile() +{ + #- Get file list from $opt_file + + my @tmp_list = `cat $opt_file`; + + foreach my $file (@tmp_list){ + chomp($file); + $file =~ s/^\s+//; # remove leading spaces + $file =~ s/\s+$//; # remove trailing spaces + + push(@file_list, $file); + } +} + sub getFileList() { + my $startSec = &date2sec($opt_startDate); + my $endSec = &date2sec($opt_endDate); + #- Loop over disks foreach my $diskNr (1..22){ my $path = sprintf("/data%02d/data", $diskNr); @@ -166,7 +197,7 @@ sub archive() my $archive = "archive"; $archive = $opt_arch if( defined $opt_arch); - my $cmd = "gstore arch \"$hldfile\" $archive \"hld\""; + my $cmd = "gstore arch \"$hldfile\" $archive \"$opt_dir\""; print "cmd: $cmd\n"; system($cmd) if( defined $opt_arch); }