Index: trunk/pstamp/scripts/pstamp_get_image_job.pl
===================================================================
--- trunk/pstamp/scripts/pstamp_get_image_job.pl	(revision 26214)
+++ trunk/pstamp/scripts/pstamp_get_image_job.pl	(revision 26215)
@@ -51,18 +51,18 @@
 $err .= "--output_base is required to specify the output fileset\n" if (!$output_base);
 
-die $err if $err;
+my_die( $err, $PS_EXIT_PROG_ERROR) if $err;
 
 my $params_file = $output_base . ".mdc";
 if (! open(INPUT, "<$params_file") ) {
-    die("failed to open params file: $params_file");
+    my_die("failed to open params file: $params_file", $PS_EXIT_UNKNOWN_ERROR);
 }
 
 my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files
 
-my $data = $mdcParser->parse(join "", (<INPUT>)) or die("failed to parse metadata config doc");
+my $data = $mdcParser->parse(join "", (<INPUT>)) or my_die("failed to parse metadata config doc", $PS_EXIT_UNKNOWN_ERROR);
 my $components = parse_md_list($data);
 my $n = scalar @$components;
 if ($n != 1) {
-    die("params file $params_file contains unexpected number of components: $n");
+    my_die("params file $params_file contains unexpected number of components: $n", $PS_EXIT_PROG_ERROR);
 }
 my $comp = $components->[0];
@@ -84,5 +84,5 @@
 
 if (!$camera or !$path_base or !$component or !$stage_id or !$stage) {
-       die "failed to parse params from: $params_file";
+       my_die("failed to parse params from: $params_file", $PS_EXIT_UNKNOWN_ERROR);
 }
 
@@ -110,10 +110,10 @@
         run(command => $command, verbose => $verbose);
     unless ($success) {
-        die("Unable to perform $command: $error_code");
+        my_die("Unable to perform $command: $error_code", $error_code >> 8);
     }
 }
 
 if (! open(RESULTS, "<$results_file")) {
-    die("failed to open bundle results file: $results_file");
+    my_die("failed to open bundle results file: $results_file", $PS_EXIT_UNKNOWN_ERROR);
 }
 
@@ -135,5 +135,5 @@
         $md5sum = $val;
     } else {
-        die("unexpected tag: $tag  found in results file: $results_file");
+        my_die("unexpected tag: $tag  found in results file: $results_file", $PS_EXIT_PROG_ERROR);
     }
 }
@@ -141,5 +141,5 @@
 my $reglist = "$out_dir/reglist$job_id";
 if (! open(REGLIST, ">$reglist") ) {
-    die("failed to open registration list: $reglist");
+    my_die("failed to open registration list: $reglist", $PS_EXIT_UNKNOWN_ERROR);
 }
 
@@ -149,2 +149,10 @@
 
 exit 0;
+
+sub my_die {
+    my $msg = shift;
+    my $rc = shift;
+
+    print STDERR $msg;
+    exit $rc ? $rc : $PS_EXIT_UNKNOWN_ERROR;
+}
