Index: trunk/pstamp/scripts/ppstamp_run.pl
===================================================================
--- trunk/pstamp/scripts/ppstamp_run.pl	(revision 16358)
+++ trunk/pstamp/scripts/ppstamp_run.pl	(revision 16591)
@@ -15,10 +15,12 @@
 my $job_id = $ARGV[0];
 
-my $verbosity = 0;
+my $verbosity = 1;
 
 use Sys::Hostname;
 my $host = hostname();
+
 print "\n\n";
 print "Starting script $0 on $host\n\n";
+
 use IPC::Cmd 0.36 qw( can_run run );
 
@@ -58,10 +60,11 @@
         run(command => $command, verbose => $verbosity);
     unless ($success) {
-        die("Unable to perform pstamptool -pendingreq: $error_code");
+        die("Unable to perform pstamptool -pendingjob: $error_code");
     }
 
     if (@$stdout_buf == 0) {
         print STDERR "pending pstamp job id $job_id not found\n";
-        exit 1;
+        # exit 1;
+        exit 0;
     }
     my $metadata = $mdcParser->parse(join "", @$stdout_buf) or
@@ -82,17 +85,4 @@
 my $outputBase = $psjob->{outputBase};
 my $argString = $psjob->{args};
-#my $request_id = $psjob->{req_id};
-
-#
-# update the state of this job from 'new' to 'run'
-#
-{
-    my $command = "$pstamptool -processedjob -job_id $job_id -state run";
-    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
-        run(command => $command, verbose => $verbosity);
-    unless ($success) {
-        die("Unable to perform $command: $error_code");
-    }
-}
 
 my $jobStatus;
@@ -103,18 +93,16 @@
 
     if ($success) {
-        $jobStatus = "ok";
+        $jobStatus = $PS_EXIT_SUCCESS;
     } else {
-        $jobStatus = $error_code;
-        print STDERR "ppstamp failed with error code $error_code\n";
+        # run shifts the unix exit status up by 8 bits for some reason
+        $jobStatus = $error_code >> 8;
+        print STDERR "ppstamp failed with error code: $jobStatus\n";
     }
-#    unless ($success) {
-#        die("Unable to perform $command: $error_code");
-#    }
 }
 
 
-# stop the job and set the error status
+# stop the job and set the result value
 {
-    my $command = "$pstamptool -processedjob -job_id $job_id -state stop -status $jobStatus";
+    my $command = "$pstamptool -processedjob -job_id $job_id -state stop -result $jobStatus";
     my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
         run(command => $command, verbose => $verbosity);
@@ -124,8 +112,3 @@
 }
 
-
-if ($jobStatus eq "ok") {
-    exit 0;
-} else {
-    exit $jobStatus;
-}
+exit $jobStatus;
