Index: trunk/ippTasks/pstamp.pro
===================================================================
--- trunk/ippTasks/pstamp.pro	(revision 18363)
+++ trunk/ippTasks/pstamp.pro	(revision 18381)
@@ -1,6 +1,11 @@
 
-# $VERBOSE = 3
-
+#$VERBOSE = 3
+
+# these variables wil cycle through the known database names
+
+$pstampDS_DB = 0
+$pstampReq_DB = 0
 $pstampJob_DB = 0
+$pstampFin_DB = 0
 
 macro pstamp.reset
@@ -65,6 +70,13 @@
 
     task.exec
-        # echo pstamp_queue_requests.pl
-        command pstamp_queue_requests.pl
+        if ($DB:n == 0)
+            option DEFAULT
+            command pstamp_queue_requests.pl --limit 5
+        else 
+            option $DB:$pstampDS_DB
+            command pstamp_queue_requests.pl --limit 5 --dbname $DB:$pstampDS_DB --verbose
+            $pstampDS_DB ++
+            if ($pstampDS_DB >= $DB:n) set pstampDS_DB = 0
+        end
     end
 
@@ -91,10 +103,17 @@
 
     task.exec
-        command pstamptool  -pendingreq
-    end
-
-    task.exit $EXIT_SUCCESS
-        ipptool2book stdout pstampRequest -key req_id -uniq -setword pantaskState INIT
-
+        if ($DB:n == 0)
+            option DEFAULT
+            command pstamptool  -pendingreq
+        else 
+            option $DB:$pstampReq_DB
+            command pstamptool  -pendingreq -dbname $DB:$pstampReq_DB
+            $pstampReq_DB ++
+            if ($pstampReq_DB >= $DB:n) set pstampReq_DB = 0
+        end
+    end
+
+    task.exit $EXIT_SUCCESS
+        ipptool2book stdout pstampRequest -key req_id -uniq -setword dbname $options:0 -setword pantaskState INIT
         if ($VERBOSE > 2)
             echo starting request
@@ -129,7 +148,9 @@
         book setword pstampRequest $pageName pantaskState RUN
         book getword pstampRequest $pageName req_id -var REQ_ID
-
-        $run = pstamp_parser_run.pl $REQ_ID
-
+        book getword pstampRequest $pageName dbname -var DBNAME
+
+        $run = pstamp_parser_run.pl --req_id $REQ_ID
+
+        add_standard_args run
         options $pageName
 
@@ -142,5 +163,5 @@
 
     task.exit default
-        echo pstamp.request.run task.exit status: $JOB_STATUS
+#        echo pstamp.request.run task.exit status: $JOB_STATUS
         process_exit pstampRequest $options:0 $JOB_STATUS
     end
@@ -161,10 +182,20 @@
 
     task.exec
-        $run = pstampfinish
-        command $run
-    end
-
+        if ($DB:n == 0)
+            option DEFAULT
+            command pstampfinish
+        else 
+            option $DB:$pstampFin_DB
+            command pstampfinish -dbname $DB:$pstampFin_DB
+            $pstampFin_DB ++
+            if ($pstampFin_DB >= $DB:n) set pstampFin_DB = 0
+        end
+    end
+
+    task.exit $EXIT_SUCCESS
+        # nothing to do
+    end
     task.exit default
-        # nothing to do
+        showcommand failure
     end
 
@@ -185,5 +216,4 @@
         if ($DB:n == 0)
             option DEFAULT
-            #echo command pstamptool -pendingjob -limit 10
             command pstamptool -pendingjob -limit 10
         else
@@ -191,5 +221,5 @@
             command pstamptool -pendingjob -limit 10 -dbname $DB:$pstampJob_DB
             $pstampJob_DB ++
-            if ($pstampJob_DB >= $DB:n) set regPendingImfile_DB = 0
+            if ($pstampJob_DB >= $DB:n) set pstampJob_DB = 0
         end
     end
@@ -197,13 +227,12 @@
     task.exit $EXIT_SUCCESS
         # echo ipptool2book stdout pstampJob -key job_id -setword dbname $options:0 -setword pantaskState INIT
-        #ipptool2book stdout pstampJob -key job_id -setword dbname $options:0 -setword pantaskState INIT
-        ipptool2book stdout pstampJob -key job_id -uniq -setword pantaskState INIT
-
+        ipptool2book stdout pstampJob -key job_id -uniq -setword dbname $options:0 -setword pantaskState INIT
+
+        book npages pstampJob -var N
         if ($VERBOSE > 2)
-            # echo book listbook pstampJob":"
-            echo starting job:
             book listbook pstampJob
         end
 
+        # delete existing entries in the appropriate pantaskStates
         process_cleanup pstampJob
     end
@@ -235,11 +264,13 @@
         book setword pstampJob $pageName pantaskState RUN
         book getword pstampJob $pageName job_id -var JOB_ID
-
-        book listpage pstampJob $pageName
-
-        $run = pstamp_job_run.pl $JOB_ID
-
-        # ppstamp_run udpates the state of the job now
-        #$run = pstamptool -processedjob -state stop -status 0 -job_id $JOB_ID
+        book getword pstampJob $pageName dbname -var DBNAME
+
+        if ($VERBOSE > 1) 
+            book listpage pstampJob $pageName
+        end
+
+
+        $run = pstamp_job_run.pl --job_id $JOB_ID
+        add_standard_args run
 
         options $pageName
