Index: trunk/ippTasks/phase3.pro
===================================================================
--- trunk/ippTasks/phase3.pro	(revision 11210)
+++ trunk/ippTasks/phase3.pro	(revision 11323)
@@ -26,4 +26,7 @@
 end
 
+# this variable will cycle through the known database names
+$phase3_DB = 0
+
 # select images ready for phase3 analysis
 # new entries are added to p3PendingExp
@@ -40,5 +43,14 @@
 
   task.exec
-    command p3tool -pendingexp -limit 20
+    if ($DB:n == 0)
+      option DEFAULT
+      command p3tool -pendingexp -limit 20
+    else
+      # save the DB name for the exit tasks
+      option $DB:$phase3_DB
+      command p3tool -pendingexp -limit 20 -dbname $DB:$phase3_DB
+      $phase3_DB ++
+      if ($phase3_DB >= $DB:n) set phase3_DB = 0
+    end
   end
 
@@ -46,5 +58,5 @@
   task.exit    0
     # convert 'stdout' to book format
-    ipptool2book stdout p3PendingExp -key exp_tag -uniq
+    ipptool2book stdout p3PendingExp -key exp_tag -uniq -setword dbname $options:0
     if ($VERBOSE > 2)
       book listbook p3PendingExp
@@ -53,4 +65,5 @@
     # delete existing entries which are DONE
     book delpage p3PendingExp -key state DONE
+    book delpage p3PendingExp -key state DATA_ERR
   end
 
@@ -70,5 +83,5 @@
   periods      -poll $runpoll
   periods      -exec $runexec
-  periods      -timeout 5
+  periods      -timeout 10
 
   task.exec
@@ -84,4 +97,7 @@
     book getword p3PendingExp $pageName camera -var CAMERA
     book getword p3PendingExp $pageName exp_tag -var EXP_TAG
+    book getword p3PendingExp $pageName workdir -var WORKDIR
+    book getword p3PendingExp $pageName dbname -var DBNAME
+    set_standard_args
 
     # specify choice of remote host:(need to choose based on chips)
@@ -92,11 +108,10 @@
     end
 
-    # XXX this is still a lame rule
-    $word = `basename $EXP_TAG | tr '.' ' '`
-    list word -split $word
-    $base = $word:0
-    stdout $LOGSUBDIR/$base/$EXP_TAG.log
-    stderr $LOGSUBDIR/$base/$EXP_TAG.log
-    exec mkdir -p $LOGSUBDIR/$base
+    # output log from filerule
+    $outroot = $WORKDIR/$EXP_TAG
+    $logfile = `ipp_filename.pl PHASE3.LOG $outroot $CLASS_ID`
+    stdout $logfile
+    stderr $logfile
+    exec mkdir -p $WORKDIR
 
     # save the pageName for future reference below
@@ -105,19 +120,12 @@
     # create the command line
     if ($VERBOSE > 1)
-      echo command phase3.pl --exp_tag $EXP_TAG
+      echo command phase3.pl --exp_tag $EXP_TAG $ARGS
     end
-    command phase3.pl --exp_tag $EXP_TAG --camera $CAMERA
+    command phase3.pl --exp_tag $EXP_TAG --camera $CAMERA $ARGS
   end
 
   # success
-  task.exit 0
-    # phase3exp.pl updates DB tables, here we just update the page
-    book setword p3PendingExp $options:0 state DONE
-  end
-
-  # default exit status
-  task.exit    default
-    showcommand failure
-    book setword p3PendingExp $options:0 state FAIL
+  task.exit default
+    process_exit p3PendingExp $options:0 $JOB_STATUS
   end
 
