Index: trunk/ippTasks/phase2.pro
===================================================================
--- trunk/ippTasks/phase2.pro	(revision 11236)
+++ trunk/ippTasks/phase2.pro	(revision 11323)
@@ -26,4 +26,7 @@
 end
 
+# this variable will cycle through the known database names
+$phase2_DB = 0
+
 # select images ready for phase2 analysis
 # new entries are added to p2PendingImfile
@@ -40,5 +43,14 @@
 
   task.exec
-    command p2tool -pendingimfile -limit 20
+    if ($DB:n == 0)
+      option DEFAULT
+      command p2tool -pendingimfile -limit 20
+    else
+      # save the DB name for the exit tasks
+      option $DB:$phase2_DB
+      command p2tool -pendingimfile -limit 20 -dbname $DB:$phase2_DB
+      $phase2_DB ++
+      if ($phase2_DB >= $DB:n) set phase2_DB = 0
+    end
   end
 
@@ -46,5 +58,5 @@
   task.exit    0
     # convert 'stdout' to book format
-    ipptool2book stdout p2PendingImfile -key exp_tag:class_id -uniq
+    ipptool2book stdout p2PendingImfile -key exp_tag:class_id -uniq -setword dbname $options:0
     if ($VERBOSE > 2)
       book listbook p2PendingImfile
@@ -53,4 +65,5 @@
     # delete existing entries which are DONE
     book delpage p2PendingImfile -key state DONE
+    book delpage p2PendingImfile -key state DATA_ERR
   end
 
@@ -87,4 +100,7 @@
     book getword p2PendingImfile $pageName class_id -var CLASS_ID
     book getword p2PendingImfile $pageName uri -var URI
+    book getword p2PendingImfile $pageName workdir -var WORKDIR
+    book getword p2PendingImfile $pageName dbname -var DBNAME
+    set_standard_args
 
     # specify choice of remote host
@@ -108,7 +124,7 @@
     # create the command line
     if ($VERBOSE > 1)
-      echo command phase2.pl --exp_tag $EXP_TAG --class_id $CLASS_ID --uri $URI --camera $CAMERA
+      echo command phase2.pl --exp_tag $EXP_TAG --class_id $CLASS_ID --uri $URI --camera $CAMERA $ARGS
     end
-    command phase2.pl --exp_tag $EXP_TAG --class_id $CLASS_ID --uri $URI --camera $CAMERA --workdir $WORKDIR
+    command phase2.pl --exp_tag $EXP_TAG --class_id $CLASS_ID --uri $URI --camera $CAMERA $ARGS
   end
 
