- Timestamp:
- Apr 14, 2023, 12:02:11 PM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/eam/rawfix.20230221/src/get_md5s_instances.pl
r42444 r42451 13 13 # USAGE: get_md5s_instances.pl --hostname (hostname) --input (file) --stage (0,1,etc) 14 14 15 my ($myhost, $input, $stage) = &parse_cmdopts; 15 my $input; 16 my ($myhost, $dateword, $topdir, $stage) = &parse_cmdopts; 16 17 17 18 # check that we are running this script on 'myhost' … … 20 21 21 22 # read the list of instances: 22 my ($ins_list_r, $dst_list_r, $md5_list_r) = &load_instance_list ( $input);23 my ($ins_list_r, $dst_list_r, $md5_list_r) = &load_instance_list (); 23 24 24 my $output = $input; 25 $output =~ s/inst.$stage/md5s/; 25 my $output = "$topdir/$dateword/$myhost.md5s.txt"; 26 26 27 if ($output eq $input) { die "output file ($output) matches input file ($input)\n"; } 28 29 # read in both instance 27 # read in existing md5s 30 28 my $out_hash_r; 31 29 if (-e $output) { … … 60 58 } 61 59 62 my $line; 63 if (0) { 64 $line = "fakevalue $filename"; # XXX TEST: disable calculation: 65 } else { 66 $line = `md5sum $filename`; 67 } 60 my $line = `md5sum $filename`; 68 61 69 62 my ($md5sum, $rawfile) = split (" ", $line); … … 73 66 exit 0; 74 67 68 # use global $topdir, $dateword, $myhost, $stage 69 sub load_instance_list { 70 my (@ins_list, @dst_list, @md5_list); 71 72 # load the master list 73 my $input = "$topdir/$dateword/$myhost.inst.$stage.txt"; 74 &load_instance_list_onefile ($input, \@ins_list, \@dst_list, \@md5_list); 75 76 # there may be additional instances in files with names like HOSTNAME.XYnn.inst.STAGE 77 my @instlist = glob ("$topdir/$dateword/$myhost.XY??.inst.$stage.txt"); 78 foreach my $infile (@instlist) { 79 &load_instance_list_onefile ($infile, \@ins_list, \@dst_list, \@md5_list); 80 } 81 return (\@ins_list, \@dst_list, \@md5_list); 82 } 83 75 84 # read the instance info 76 sub load_instance_list {85 sub load_instance_list_onefile { 77 86 my $infile = $_[0]; 78 79 my (@ins_list, @dst_list, @md5_list); 87 my $ins_list_r = $_[1]; # reference to the instance list array 88 my $dst_list_r = $_[2]; # reference to the instance list array 89 my $md5_list_r = $_[3]; # reference to the instance list array 80 90 81 91 open(FILE,$infile) or die "cannot open file $infile\n"; … … 89 99 90 100 if (@words != 3) { die "error in input $infile : $line\n"; } 91 push (@ ins_list, $words[0]);92 push (@ dst_list, $words[1]);93 push (@ md5_list, $words[2]);101 push (@$ins_list_r, $words[0]); 102 push (@$dst_list_r, $words[1]); 103 push (@$md5_list_r, $words[2]); 94 104 } 95 105 close (FILE); 96 97 return (\@ins_list, \@dst_list, \@md5_list);98 106 } 99 107 … … 123 131 sub parse_cmdopts { 124 132 125 my ($myhost, $ input, $stage);126 GetOptions( 'hostname=s' => \$myhost, ' input=s' => \$input, 'stage=s' => \$stage) || pod2usage(2);133 my ($myhost, $topdir, $dateobs, $stage); 134 GetOptions( 'hostname=s' => \$myhost, 'topdir=s' => \$topdir, 'dateobs=s' => \$dateobs, 'stage=s' => \$stage) || pod2usage(2); 127 135 128 pod2usage( -msg => "Provide the input list with --input", -exitval => 2) unless defined $input; 136 pod2usage( -msg => "Cannot determine target date, use --dateobs YYYYMMDD", -exitval => 2) unless defined $dateobs; 137 # pod2usage( -msg => "Provide the input list with --input", -exitval => 2) unless defined $input; 129 138 pod2usage( -msg => "Define the host machine with --hostname", -exitval => 2) unless defined $myhost; 130 139 pod2usage( -msg => "Define the stage (0, 1, etc) with --stage", -exitval => 2) unless defined $stage; 140 pod2usage( -msg => "Specify the top-level output directory with --topdir", -exitval => 2) unless defined $topdir; 131 141 132 142 # check that stage is an integer … … 134 144 unless ($stage >= 0) { die "stage must be a non-negative integer\n"; } 135 145 136 return ($myhost, $ input, $stage);146 return ($myhost, $dateobs, $topdir, $stage); 137 147 } 138 148
Note:
See TracChangeset
for help on using the changeset viewer.
