Index: trunk/ippTasks/pstamp.pro
===================================================================
--- trunk/ippTasks/pstamp.pro	(revision 18568)
+++ trunk/ippTasks/pstamp.pro	(revision 18589)
@@ -12,4 +12,5 @@
     book init pstampRequest
     book init pstampJob
+    book init pstampFinish
 end
 
@@ -27,5 +28,9 @@
         active true
     end
-    task pstamp.request.finish
+
+    task request.finish.load
+        active true
+    end
+    task request.finish.run
         active true
     end
@@ -49,5 +54,8 @@
         active false
     end
-    task pstamp.request.finish
+    task request.finish.load
+        active false
+    end
+    task request.finish.run
         active false
     end
@@ -173,10 +181,10 @@
 end
 
-task pstamp.request.finish
-    #periods     -poll $RUNPOLL
-    #periods     -exec $RUNEXEC
-    periods     -poll $RUNPOLL
-    periods     -exec 5
-    periods     -timeout 30
+task request.finish.load
+    host        local
+
+    periods     -poll $LOADPOLL
+    periods     -exec $LOADEXEC
+    periods     -timeout 300
     npending    1
 
@@ -184,8 +192,8 @@
         if ($DB:n == 0)
             option DEFAULT
-            command pstamp_finish.pl --limit 10 --verbose
+            command pstamptool  -completedreq
         else 
             option $DB:$pstampFin_DB
-            command pstamp_finish.pl --dbname $DB:$pstampFin_DB --limit 10 --verbose
+            command pstamptool  -completedreq -dbname $DB:$pstampFin_DB
             $pstampFin_DB ++
             if ($pstampFin_DB >= $DB:n) set pstampFin_DB = 0
@@ -194,12 +202,60 @@
 
     task.exit $EXIT_SUCCESS
-        # nothing to do
-    end
+        ipptool2book stdout pstampFinish -key req_id -uniq -setword dbname $options:0 -setword pantaskState INIT
+        if ($VERBOSE > 2)
+            book listbook pstampFinish
+        end
+
+        process_cleanup pstampFinish
+    end
+
+    task.exit   default
+        showcommand failure
+    end
+
+    task.exit   timeout
+        showcommand timeout
+    end
+end
+
+task request.finish.run
+    periods     -poll $RUNPOLL
+    periods     -exec $RUNEXEC
+    periods     -timeout 30
+    npending    1
+
+    task.exec
+        book npages pstampFinish -var N
+        if ($N == 0) break
+        
+        book getpage pstampFinish 0 -var pageName -key pantaskState INIT
+        if ("$pageName" == "NULL") break
+
+        book setword pstampFinish $pageName pantaskState RUN
+        book getword pstampFinish $pageName req_id -var REQ_ID
+        book getword pstampFinish $pageName dbname -var DBNAME
+        book getword pstampFinish $pageName reqType -var REQ_TYPE
+        book getword pstampFinish $pageName name -var REQ_NAME
+        book getword pstampFinish $pageName outProduct -var PRODUCT
+
+        $run = request_finish.pl --req_id $REQ_ID --req_type $REQ_TYPE --req_name $REQ_NAME --product $PRODUCT
+
+        add_standard_args run
+        options $pageName
+
+        if ($VERBOSE > 1) 
+            echo command $run
+        end
+        command $run
+    end
+
     task.exit default
-        showcommand failure
+        echo request.finish.run task.exit status: $JOB_STATUS
+        process_exit pstampFinish $options:0 $JOB_STATUS
     end
 
     task.exit timeout
         showcommand timeout
+        book setword pstampFinish $options:0 pantaskState TIMEOUT.run
     end
 end
