Index: trunk/pstamp/web/request.php
===================================================================
--- trunk/pstamp/web/request.php	(revision 16358)
+++ trunk/pstamp/web/request.php	(revision 16960)
@@ -13,5 +13,5 @@
 
 $COMMAND_DIR = "/export/data0/bills/src/ipp/pstamp/scripts";
-$STAMPS_DIR = "/export/data1/bills/pstamp/work/stamps";
+//$STAMPS_DIR = "/export/data1/bills/pstamp/work/stamps";
 
 // Initialize variables
@@ -142,10 +142,11 @@
             $command_line = build_command_line();
             $error_line = "";
-            run_command();
+            run_command($command_line);
             if (! $list_checked) {
                 // The only output from a successful run is the request_id
                 $request_id = Array_pop($output_array);
                 $last_request_id = $request_id;
-                #echo "The request id is $request_id\n";
+                setcookie("our_request_id", $request_id);
+                // echo "The request id is $request_id\n";
                 if (count($output_array) != 0) {
                     throw new Exception("unexpected output returned by pstampwebrequest.");
@@ -175,4 +176,5 @@
         }
     }
+    listJobs($last_request_id);
 }
 
@@ -190,5 +192,4 @@
     global $rvar_id, $rvar_class_id;
     global $command_line;
-    global $STAMPS_DIR;
 
     $cmd = "pstamp_runcommand.sh pstamp_webrequest.pl";
@@ -205,5 +206,5 @@
         throw new Exception('Stamp Name must be specified.');
     }
-    $cmd .= " -user_tag $STAMPS_DIR/$rvar_user_tag";
+    $cmd .= " -user_tag $rvar_user_tag";
 
     // Set up the ROI parameters
@@ -262,7 +263,6 @@
 }
 
-function run_command()
+function run_command($command_line)
 {
-    global $command_line;
     global $output_array;
     global $error_line;
@@ -349,15 +349,33 @@
 }
 
+function listJobs($request_id)
+{
+    $command_line = "pstamp_runcommand.sh pstamp_listjobs.pl $request_id";
+    run_command($command_line);
+}
+
 function getRequestStatus()
 {
     global $request_id;
-    global $command_line;
     global $command_status;
-
-    $command_line = "pstamp_runcommand.sh pstamp_listjobs.pl $request_id";
-    run_command();
-
+    global $output_array;
+
+    $command_line = "pstamp_runcommand.sh pstamptool -listreq -req_id $request_id -simple";
+    run_command($command_line);
     if ($command_status == 0) {
-        return countRunningJobs();
+        $size = sizeof($output_array);
+        $runningReq = 0;
+        for ($i = 0; $i < $size; $i++) {
+            $elements = explode(" ", $output_array[$i]);
+            if (count($elements) >= 3) {
+                $state = $elements[2];
+                if ($state != "stop") {
+                    $runningReq++;
+                }
+            } else {
+                throw new Exception ("incorrect data in job status: $output_array[$i]");
+            }
+        }
+        return $runningReq;
     } else {
         return 0;
