Index: /trunk/tools/eam/rawfix.20230221/src/check.rawfix.sh
===================================================================
--- /trunk/tools/eam/rawfix.20230221/src/check.rawfix.sh	(revision 42405)
+++ /trunk/tools/eam/rawfix.20230221/src/check.rawfix.sh	(revision 42406)
@@ -66,4 +66,10 @@
   if ($mystate == "md5sum.done") goto good_state
   if ($mystate == "md5sum.fail") goto good_state
+  if ($mystate == "ckchip.new") goto good_state
+  if ($mystate == "ckchip.done") goto good_state
+  if ($mystate == "ckchip.fail") goto good_state
+  if ($mystate == "fixchip.new") goto good_state
+  if ($mystate == "fixchip.done") goto good_state
+  if ($mystate == "fixchip.fail") goto good_state
 
   echo "ERROR: unknown mode $mystate"
Index: /trunk/tools/eam/rawfix.20230221/src/check_chip_locations.pl
===================================================================
--- /trunk/tools/eam/rawfix.20230221/src/check_chip_locations.pl	(revision 42405)
+++ /trunk/tools/eam/rawfix.20230221/src/check_chip_locations.pl	(revision 42406)
@@ -103,5 +103,7 @@
 ### in order to use this, I need to choose the target volume
 
-die "done";
+exit 0;
+
+# die "done";
 
 sub vsystem {
Index: /trunk/tools/eam/rawfix.20230221/src/fix_chip_locations.pl
===================================================================
--- /trunk/tools/eam/rawfix.20230221/src/fix_chip_locations.pl	(revision 42405)
+++ /trunk/tools/eam/rawfix.20230221/src/fix_chip_locations.pl	(revision 42406)
@@ -99,5 +99,5 @@
 print "Nxbck: $Nxbck\n";
 
-die "all done";
+exit 0;
 
 sub get_new_instance {
Index: /trunk/tools/eam/rawfix.20230221/src/rawfix.ckchip.pt
===================================================================
--- /trunk/tools/eam/rawfix.20230221/src/rawfix.ckchip.pt	(revision 42405)
+++ /trunk/tools/eam/rawfix.20230221/src/rawfix.ckchip.pt	(revision 42406)
@@ -86,12 +86,11 @@
   end
 
+  ## XX delete the page from the book if done?
   task.exit 0
     # convert the stdout 'queue' to entries in a book
     # fields in the table will become words in the page
-    queuesize stdout -var Nhosts
-    queue2book -raw-columns -key dateobs:md5host -uniq -setword pantaskState INIT stdout md5host.book
-    book setword ckchip.book $options:0 NHOST {$Nhosts - 1}
-    book setword ckchip.book $options:0 NDONE 0
     # use the queuesize (Nhosts) to track how many jobs are done / to be done
+    exec update.rawfix.sh $options:0 ckchip.done
+    book delpage ckchip.book $options:0
   end
 
@@ -100,4 +99,5 @@
     showcommand failure
     book setword ckchip.book $options:0 pantasksQuality FAIL
+    exec update.rawfix.sh $options:0 ckchip.fail
   end
 
@@ -105,4 +105,5 @@
     showcommand crash
     book setword ckchip.book $options:0 pantasksQuality CRASH
+    exec update.rawfix.sh $options:0 ckchip.fail
   end
 
@@ -111,4 +112,5 @@
     showcommand timeout
     book setword ckchip.book $options:0 pantasksQuality TIMEOUT
+    exec update.rawfix.sh $options:0 ckchip.fail
   end
 end
Index: /trunk/tools/eam/rawfix.20230221/src/rawfix.fixchip.pt
===================================================================
--- /trunk/tools/eam/rawfix.20230221/src/rawfix.fixchip.pt	(revision 42406)
+++ /trunk/tools/eam/rawfix.20230221/src/rawfix.fixchip.pt	(revision 42406)
@@ -0,0 +1,117 @@
+## pantasks scripts to manage the raw exposure data repair / cleanup
+## this is for the initial chip instance checks
+## use the top-level rawfix.pt to load
+
+# these tasks run the steps: 
+# -- check_chip_locations.pl --dateobs YYYY/MM/DD --chiplist file.txt
+# -- fix_chip_locations.pl --dateobs (YYYY/MM/DD)
+
+if (not($?RAWFIX_FIXCHIP_INIT))
+  book init fixchip.book
+  $RAWFIX_FIXCHIP_INIT = 1
+end
+
+# select nights in state fixchip.new
+# output: fixchip.book
+task nights.fixchip.load
+  host local
+  periods -poll $TPOLL
+  periods -exec $TEXEC
+  periods -timeout 30
+
+  stdout $LOGDIR/fixchip.load.stdout.log  
+  stderr $LOGDIR/fixchip.load.stderr.log
+
+  # only run one of these tasks at a time
+  npending 1
+
+  task.exec
+    # command check.rawfix.sh state ckchip.done
+    command check.rawfix.sh state fixchip.new 
+  end
+
+  task.exit 0
+    # convert the stdout 'queue' to entries in a book
+    # fields in the table will become words in the page
+    queue2book -raw-columns -key dateobs -uniq -setword pantaskState INIT -setword pantasksQuality OK stdout fixchip.book
+  end
+
+  # exit values other than 0:
+  task.exit    default
+    showcommand failure
+  end
+
+  task.exit    crash
+    showcommand crash
+  end
+
+  # operation times out?
+  task.exit    timeout
+    showcommand timeout
+  end
+end
+
+task nights.fixchip.run
+
+  periods      -poll $RPOLL
+  periods      -exec $REXEC
+  periods      -timeout 60
+  npending 1
+
+  stdout $LOGDIR/fixchip.run.stdout.log  
+  stderr $LOGDIR/fixchip.run.stderr.log
+
+  task.exec
+    # if we are unable to run the 'exec', use a long retry time
+    periods -exec $REXEC
+
+    book npages fixchip.book -var N
+    if ($N == 0) break
+    if ($NETWORK == 0) break
+    
+    # look for new nights in fixchip.book (pantaskState == INIT)
+    book getpage fixchip.book 0 -var pageName -key pantaskState INIT
+    if ("$pageName" == "NULL") break
+
+    book setword fixchip.book $pageName pantaskState RUN
+    book getword fixchip.book $pageName dateobs -var DATEOBS
+    option $pageName
+
+    substr $DATEOBS 0 4 YEAR
+    substr $DATEOBS 4 2 MONTH
+    substr $DATEOBS 6 2 DAY
+    sprintf FULLDATE "%s/%s/%s" $YEAR $MONTH $DAY
+
+    command fix_chip_locations.pl --dateobs $FULLDATE --chiplist gpc1.chips.txt
+  end
+
+  ## XX delete the page from the book if done?
+  task.exit 0
+    # convert the stdout 'queue' to entries in a book
+    # fields in the table will become words in the page
+    # use the queuesize (Nhosts) to track how many jobs are done / to be done
+    exec update.rawfix.sh $options:0 fixchip.done
+    book delpage fixchip.book $options:0
+  end
+
+  # exit values other than 0:
+  task.exit    default
+    showcommand failure
+    book setword fixchip.book $options:0 pantasksQuality FAIL
+    exec update.rawfix.sh $options:0 fixchip.fail
+  end
+
+  task.exit    crash
+    showcommand crash
+    book setword fixchip.book $options:0 pantasksQuality CRASH
+    exec update.rawfix.sh $options:0 fixchip.fail
+  end
+
+  # operation times out?
+  task.exit    timeout
+    showcommand timeout
+    book setword fixchip.book $options:0 pantasksQuality TIMEOUT
+    exec update.rawfix.sh $options:0 fixchip.fail
+  end
+end
+
Index: /trunk/tools/eam/rawfix.20230221/src/rawfix.pt
===================================================================
--- /trunk/tools/eam/rawfix.20230221/src/rawfix.pt	(revision 42405)
+++ /trunk/tools/eam/rawfix.20230221/src/rawfix.pt	(revision 42406)
@@ -1,7 +1,3 @@
 ## pantasks scripts to manage the raw exposure data repair / cleanup
-
-#### the scripts below take the input files (YYYYMMDD/*.inst.txt) 
-#### and run get_md5s_instances.pl on the hosts associated with those lists
-#### the outputs are files (YYYYMMDD/*.md5s.txt) 
 
 $TPOLL = 5
@@ -20,6 +16,6 @@
 end
 
-input rawfix.setup.pt
-input rawfix.md5sum.pt
+input rawfix.ckchip.pt
+# input rawfix.md5sum.pt
 
 ######################### UTILITIES #################################
