Index: trunk/tools/eam/rawfix.20230221/src/fix_chip_failures.pl
===================================================================
--- trunk/tools/eam/rawfix.20230221/src/fix_chip_failures.pl	(revision 42442)
+++ trunk/tools/eam/rawfix.20230221/src/fix_chip_failures.pl	(revision 42442)
@@ -0,0 +1,85 @@
+#! /usr/bin/env perl
+
+# NOTE: in this script, we are using database connections to both NEBULOUS and GPC1 databases
+my $DEBUG = 3;
+my $time = time();
+
+use DBI;
+use Carp;
+use Pod::Usage qw( pod2usage );
+
+use strict;
+use warnings FATAL => qw( all );
+use Getopt::Long qw( GetOptions :config auto_help auto_version );
+
+# USAGE: fix_chip_failures.pl --dateobs (night) --chiplist (file) --stage (v0,v1,etc)
+# USAGE: fix_chip_failures.pl --dateobs 2010/05/01 --chiplist gpc1.chips.txt --stage v0
+
+my ($fulldate, $dateword, $chiplist, $stage, $topdir) = &parse_cmdopts;
+
+
+my (@instance, @data_state, @md5tru, @md5obs) = &load_failures;
+
+sub load_failures {
+
+    my (@instance, @data_state, @md5tru, @md5obs);
+
+    # given a night, load the failures from log.md5chk.v0
+    open (INLOG, "$topdir/$dateword/log.md5chk.$stage");
+    my @lines = <INLOG>;
+
+    foreach my $line (@lines) {
+	chomp $line;
+	unless ($line =~ /^FAIL:/) { next; } # skip lines with leading #
+	my @words = split (/\s+/,$line);
+
+	if (@words != 5) { die "error in log output $line\n"; }
+
+	push (@instance,   $words[1]);
+	push (@data_state, $words[2]);
+	push (@md5tru,     $words[3]);
+	push (@md5obs,     $words[4]);
+    }
+    close (CHIPS);
+
+    return (@instance, @data_state, @md5tru, @md5obs);
+}
+
+sub parse_cmdopts {
+
+    my ($dateobs, $chiplist, $stage, $topdir);
+    GetOptions( 'dateobs=s' => \$dateobs, 'chiplist=s' => \$chiplist, 'topdir=s' => \$topdir, 'stage=s' => \$stage) || pod2usage(2);
+    
+    pod2usage( -msg => "Cannot determine target date, use --dateobs YYYY/MM/DD", -exitval => 2) unless defined $dateobs;
+    pod2usage( -msg => "Provide a list of chips with --chiplist", -exitval => 2) unless defined $chiplist;
+    pod2usage( -msg => "Define the stage (v0, v1, etc) with --stage", -exitval => 2) unless defined $stage;
+    pod2usage( -msg => "Specify the top-level output directory with --topdir", -exitval => 2) unless defined $topdir;
+    
+    # check the date format (require YYYY/MM/DD and use that from 00:00:00 to 23:59:59 or take start and end?)
+
+    my ($date_year, $date_month, $date_day) = split "/",$dateobs;
+    pod2usage( -msg => "Cannot interpret date, use YYYY/MM/DD", -exitval => 2) unless defined $date_year and defined $date_month and defined $date_day;
+    pod2usage( -msg => "Cannot interpret date, use YYYY/MM/DD", -exitval => 2) if ($date_year < 2008) or ($date_year > 2030);
+    pod2usage( -msg => "Cannot interpret date, use YYYY/MM/DD", -exitval => 2) if ($date_month < 1) or ($date_month > 12);
+    pod2usage( -msg => "Cannot interpret date, use YYYY/MM/DD", -exitval => 2) if ($date_day < 1) or ($date_day > 31);
+
+    my $fulldate = "$date_year/$date_month/$date_day";
+    my $dateword = sprintf ("%4d%02d%02d", $date_year, $date_month, $date_day);
+
+    return ($fulldate, $dateword, $chiplist, $stage, $topdir) 
+}
+
+# identify the 
+
+sub neb_reverse {
+
+    my (@neb_path) = split /\//, $file;
+    my $neb_key = $neb_path[-1];
+    # Remove ins_id
+    $neb_key =~ s/^\d+\.//;
+    # Convert colons to slashes.
+    $neb_key =~ s%:%/%g;
+    $neb_key =~ s%.fz$%%;
+    print "$neb_key\n";
+}
+
Index: trunk/tools/eam/rawfix.20230221/src/queue.rawfix.sh
===================================================================
--- trunk/tools/eam/rawfix.20230221/src/queue.rawfix.sh	(revision 42441)
+++ trunk/tools/eam/rawfix.20230221/src/queue.rawfix.sh	(revision 42442)
@@ -18,4 +18,6 @@
   set filename = $2
 
+  # validate the list: could be DATE STATE or just DATE (prcol 1)?
+
   # just a big list of dates?
   foreach night (`cat $filename`)
@@ -27,4 +29,7 @@
 if ($mode == "night") then
   ## XXX validate the format (YYYYMMDD)?
+
+ XXXXX:
+
   set mynight = $2
   
