Index: trunk/ippScripts/scripts/camera_exp.pl
===================================================================
--- trunk/ippScripts/scripts/camera_exp.pl	(revision 23294)
+++ trunk/ippScripts/scripts/camera_exp.pl	(revision 23295)
@@ -367,4 +367,6 @@
     my $exit_code = shift; # Exit code to add
 
+    $exit_code = $PS_EXIT_PROG_ERROR unless defined $exit_code;
+
     carp($msg);
     if (defined $cam_id and not $no_update) {
Index: trunk/ippScripts/scripts/chip_imfile.pl
===================================================================
--- trunk/ippScripts/scripts/chip_imfile.pl	(revision 23294)
+++ trunk/ippScripts/scripts/chip_imfile.pl	(revision 23295)
@@ -248,4 +248,6 @@
     # run_state, outputImage, and outroot are globals
 
+    $exit_code = $PS_EXIT_PROG_ERROR unless defined $exit_code;
+
     carp($msg);
     if (defined $chip_id and defined $class_id and not $no_update) {
Index: trunk/ippScripts/scripts/detrend_correct_imfile.pl
===================================================================
--- trunk/ippScripts/scripts/detrend_correct_imfile.pl	(revision 23294)
+++ trunk/ippScripts/scripts/detrend_correct_imfile.pl	(revision 23295)
@@ -124,4 +124,6 @@
     my $exit_code = shift; # Exit code to add
 
+    $exit_code = $PS_EXIT_PROG_ERROR unless defined $exit_code;
+
     carp($msg);
     if (defined $det_id and defined $class_id and not $no_update) {
Index: trunk/ippScripts/scripts/detrend_norm_apply.pl
===================================================================
--- trunk/ippScripts/scripts/detrend_norm_apply.pl	(revision 23294)
+++ trunk/ippScripts/scripts/detrend_norm_apply.pl	(revision 23295)
@@ -196,4 +196,6 @@
     my $exit_code = shift;      # Exit code to add
 
+    $exit_code = $PS_EXIT_PROG_ERROR unless defined $exit_code;
+
     carp($msg);
     if (defined $det_id and defined $iter and defined $class_id and not $no_update) {
Index: trunk/ippScripts/scripts/detrend_norm_calc.pl
===================================================================
--- trunk/ippScripts/scripts/detrend_norm_calc.pl	(revision 23294)
+++ trunk/ippScripts/scripts/detrend_norm_calc.pl	(revision 23295)
@@ -230,4 +230,6 @@
     my $exit_code = shift;      # Exit code to add
 
+    $exit_code = $PS_EXIT_PROG_ERROR unless defined $exit_code;
+
     carp($msg);
     if (defined $det_id and defined $iter and not $no_update) {
Index: trunk/ippScripts/scripts/detrend_norm_exp.pl
===================================================================
--- trunk/ippScripts/scripts/detrend_norm_exp.pl	(revision 23294)
+++ trunk/ippScripts/scripts/detrend_norm_exp.pl	(revision 23295)
@@ -183,4 +183,6 @@
     my $exit_code = shift; # Exit code to add
 
+    $exit_code = $PS_EXIT_PROG_ERROR unless defined $exit_code;
+
     carp($msg);
     if (defined $det_id and defined $iter and not $no_update) {
Index: trunk/ippScripts/scripts/detrend_process_exp.pl
===================================================================
--- trunk/ippScripts/scripts/detrend_process_exp.pl	(revision 23294)
+++ trunk/ippScripts/scripts/detrend_process_exp.pl	(revision 23295)
@@ -198,4 +198,6 @@
     my $exit_code = shift; # Exit code to add
 
+    $exit_code = $PS_EXIT_PROG_ERROR unless defined $exit_code;
+
     carp($msg);
     if (defined $det_id and defined $exp_id and not $no_update) {
Index: trunk/ippScripts/scripts/detrend_process_imfile.pl
===================================================================
--- trunk/ippScripts/scripts/detrend_process_imfile.pl	(revision 23294)
+++ trunk/ippScripts/scripts/detrend_process_imfile.pl	(revision 23295)
@@ -185,4 +185,6 @@
     my $exit_code = shift; # Exit code to add
 
+    $exit_code = $PS_EXIT_PROG_ERROR unless defined $exit_code;
+
     carp($msg);
     if (defined $det_id and defined $exp_id and defined $class_id and not $no_update) {
Index: trunk/ippScripts/scripts/detrend_reject_exp.pl
===================================================================
--- trunk/ippScripts/scripts/detrend_reject_exp.pl	(revision 23294)
+++ trunk/ippScripts/scripts/detrend_reject_exp.pl	(revision 23295)
@@ -336,4 +336,6 @@
     my $exit_code = shift; # Exit code to add
 
+    $exit_code = $PS_EXIT_PROG_ERROR unless defined $exit_code;
+
     carp($msg);
     if (defined $det_id and defined $iter and not $no_update) {
Index: trunk/ippScripts/scripts/detrend_resid_exp.pl
===================================================================
--- trunk/ippScripts/scripts/detrend_resid_exp.pl	(revision 23294)
+++ trunk/ippScripts/scripts/detrend_resid_exp.pl	(revision 23295)
@@ -107,5 +107,5 @@
     }
     if (@$stdout_buf == 0) {
-	&my_die("No normalizations were found", $det_id, $iter, $PS_EXIT_PROG_ERROR);
+        &my_die("No normalizations were found", $det_id, $iter, $PS_EXIT_PROG_ERROR);
     }
 
@@ -126,9 +126,9 @@
     print "saving norms to $normsName\n";
     foreach my $norm (@$normsMD) {
-	my $class_id = $norm->{class_id};
-	my $normalization = $norm->{norm};
-
-	$norms{$class_id} = $normalization;
-        printf $normsFile "$class_id F32 $normalization\n", 
+        my $class_id = $norm->{class_id};
+        my $normalization = $norm->{norm};
+
+        $norms{$class_id} = $normalization;
+        printf $normsFile "$class_id F32 $normalization\n",
     }
     close $normsFile;
@@ -153,5 +153,5 @@
     }
     if (@$stdout_buf == 0) {
-	&my_die("No imfiles were found", $det_id, $iter, $PS_EXIT_PROG_ERROR);
+        &my_die("No imfiles were found", $det_id, $iter, $PS_EXIT_PROG_ERROR);
     }
 
@@ -168,40 +168,40 @@
     # also, write out the modified metadata set
     foreach my $mdItem (@$metadata) {
-	if ($mdItem->{class} ne "metadata") {
-	    carp "MD element ", $mdItem->{name}, " isn't of type METADATA --- ignored.\n";
-	    next;
-	}
-	my %hash;		# Hash element
-	my $mdComponents = $mdItem->{value}; # Components of the metadata
-
-	# determine the class_id for this block:
-	my $class_id;
-	foreach my $data (@$mdComponents) {
-	    unless ($data->{name} eq "class_id") { next; }
-	    $class_id = $data->{value};
-	    last;
-	}
-
-	# a new metadata block
-	print $statFile "rawResidImfile  METADATA\n";
-
-	# modify and save the data in this block:
-	foreach my $data (@$mdComponents) {
-	    my $norm = $norms{$class_id};
-
-	    # fields to modify by the normalization:
-	    if ($data->{name} eq "bg")            { $data->{value} *= $norm; }
-	    if ($data->{name} eq "bg_stdev")      { $data->{value} *= $norm; }
-	    if ($data->{name} eq "bg_mean_stdev") { $data->{value} *= $norm; }
-	    if ($data->{name} eq "bg_skewness")   { $data->{value} *= $norm; }
-	    if ($data->{name} eq "bg_kurtosis")   { $data->{value} *= $norm; }
-	    if ($data->{name} eq "bin_stdev")     { $data->{value} *= $norm; }
-
-	    # write out the metadata, save on the array of hashes
-	    print $statFile "  $data->{name}  $data->{type}  $data->{value}\n";
-	    $hash{$data->{name}} = $data->{value};
-	}
-	print $statFile "END\n";
-	push @files, \%hash;
+        if ($mdItem->{class} ne "metadata") {
+            carp "MD element ", $mdItem->{name}, " isn't of type METADATA --- ignored.\n";
+            next;
+        }
+        my %hash;               # Hash element
+        my $mdComponents = $mdItem->{value}; # Components of the metadata
+
+        # determine the class_id for this block:
+        my $class_id;
+        foreach my $data (@$mdComponents) {
+            unless ($data->{name} eq "class_id") { next; }
+            $class_id = $data->{value};
+            last;
+        }
+
+        # a new metadata block
+        print $statFile "rawResidImfile  METADATA\n";
+
+        # modify and save the data in this block:
+        foreach my $data (@$mdComponents) {
+            my $norm = $norms{$class_id};
+
+            # fields to modify by the normalization:
+            if ($data->{name} eq "bg")            { $data->{value} *= $norm; }
+            if ($data->{name} eq "bg_stdev")      { $data->{value} *= $norm; }
+            if ($data->{name} eq "bg_mean_stdev") { $data->{value} *= $norm; }
+            if ($data->{name} eq "bg_skewness")   { $data->{value} *= $norm; }
+            if ($data->{name} eq "bg_kurtosis")   { $data->{value} *= $norm; }
+            if ($data->{name} eq "bin_stdev")     { $data->{value} *= $norm; }
+
+            # write out the metadata, save on the array of hashes
+            print $statFile "  $data->{name}  $data->{type}  $data->{value}\n";
+            $hash{$data->{name}} = $data->{value};
+        }
+        print $statFile "END\n";
+        push @files, \%hash;
     }
     close $statFile;
@@ -633,4 +633,6 @@
     my $exit_code = shift; # Exit code to add
 
+    $exit_code = $PS_EXIT_PROG_ERROR unless defined $exit_code;
+
     carp($msg);
     if (defined $det_id and defined $iter and defined $exp_id and not $no_update) {
Index: trunk/ippScripts/scripts/detrend_resid_imfile.pl
===================================================================
--- trunk/ippScripts/scripts/detrend_resid_imfile.pl	(revision 23294)
+++ trunk/ippScripts/scripts/detrend_resid_imfile.pl	(revision 23295)
@@ -251,4 +251,6 @@
     my $exit_code = shift; # Exit code to add
 
+    $exit_code = $PS_EXIT_PROG_ERROR unless defined $exit_code;
+
     carp($msg);
     if (defined $det_id and defined $iter and defined $exp_id and not $no_update) {
Index: trunk/ippScripts/scripts/detrend_stack.pl
===================================================================
--- trunk/ippScripts/scripts/detrend_stack.pl	(revision 23294)
+++ trunk/ippScripts/scripts/detrend_stack.pl	(revision 23295)
@@ -251,4 +251,6 @@
     my $exit_code = shift; # Exit code to add
 
+    $exit_code = $PS_EXIT_PROG_ERROR unless defined $exit_code;
+
     carp($msg);
     if (defined $det_id and defined $iter and defined $class_id and not $no_update) {
Index: trunk/ippScripts/scripts/diff_skycell.pl
===================================================================
--- trunk/ippScripts/scripts/diff_skycell.pl	(revision 23294)
+++ trunk/ippScripts/scripts/diff_skycell.pl	(revision 23295)
@@ -276,4 +276,6 @@
     my $exit_code = shift;      # Exit code to add
 
+    $exit_code = $PS_EXIT_PROG_ERROR unless defined $exit_code;
+
     warn($msg);
     if (defined $diff_id and defined $skycell_id and not $no_update) {
Index: trunk/ippScripts/scripts/dist_advancerun.pl
===================================================================
--- trunk/ippScripts/scripts/dist_advancerun.pl	(revision 23294)
+++ trunk/ippScripts/scripts/dist_advancerun.pl	(revision 23295)
@@ -130,4 +130,6 @@
     my $exit_code = shift;      # Exit code to add
 
+    $exit_code = $PS_EXIT_PROG_ERROR unless defined $exit_code;
+
     my $command = "$disttool -updaterun";
     $command   .= " -dist_id $dist_id";
Index: trunk/ippScripts/scripts/dist_component.pl
===================================================================
--- trunk/ippScripts/scripts/dist_component.pl	(revision 23294)
+++ trunk/ippScripts/scripts/dist_component.pl	(revision 23295)
@@ -122,5 +122,5 @@
 if (-e $tmpdir) {
     if (-d $tmpdir) {
-        my $rc = system "rm -r $tmpdir"; 
+        my $rc = system "rm -r $tmpdir";
         &my_die("cannot rm $tmpdir return code: $rc", $dist_id, $component, $PS_EXIT_UNKNOWN_ERROR) if $rc;
     } else {
@@ -272,5 +272,5 @@
         my $clean_mdc = join "", @data;
 
-        my $mdlist = $mdcParser->parse($clean_mdc) or 
+        my $mdlist = $mdcParser->parse($clean_mdc) or
                 &my_die("failed to parse clean.mdc", $dist_id, $component, $PS_EXIT_UNKNOWN_ERROR);
 
@@ -293,6 +293,6 @@
             next if $rule eq "STAGE";
             my $keep_on_clean = $product_list->{$rule};
-            my $fn = $ipprc->filename($rule, $path_base, $component) or 
-                &my_die("Missing entry from camera config: $rule", $dist_id, $component, 
+            my $fn = $ipprc->filename($rule, $path_base, $component) or
+                &my_die("Missing entry from camera config: $rule", $dist_id, $component,
                     $PS_EXIT_CONFIG_ERROR);
     #        printf "%-16.16s\t%s\t%s\n",  $rule, $clean, $fn;
@@ -323,4 +323,6 @@
     my $exit_code = shift;      # Exit code to add
 
+    $exit_code = $PS_EXIT_PROG_ERROR unless defined $exit_code;
+
     my $command = "$disttool -addprocessedcomponent";
     $command   .= " -dist_id $dist_id";
Index: trunk/ippScripts/scripts/fake_imfile.pl
===================================================================
--- trunk/ippScripts/scripts/fake_imfile.pl	(revision 23294)
+++ trunk/ippScripts/scripts/fake_imfile.pl	(revision 23295)
@@ -206,4 +206,6 @@
     my $exit_code = shift; # Exit code to add
 
+    $exit_code = $PS_EXIT_PROG_ERROR unless defined $exit_code;
+
     carp($msg);
     if (defined $exp_id and defined $fake_id and defined $class_id and not $no_update) {
Index: trunk/ippScripts/scripts/magic_destreak.pl
===================================================================
--- trunk/ippScripts/scripts/magic_destreak.pl	(revision 23294)
+++ trunk/ippScripts/scripts/magic_destreak.pl	(revision 23295)
@@ -267,4 +267,6 @@
     my $exit_code = shift;      # Exit code to add
 
+    $exit_code = $PS_EXIT_PROG_ERROR unless defined $exit_code;
+
     my $command = "$magicdstool -adddestreakedfile";
     $command   .= " -magic_ds_id $magic_ds_id";
Index: trunk/ippScripts/scripts/magic_mask.pl
===================================================================
--- trunk/ippScripts/scripts/magic_mask.pl	(revision 23294)
+++ trunk/ippScripts/scripts/magic_mask.pl	(revision 23295)
@@ -146,4 +146,6 @@
     my $exit_code = shift;      # Exit code to add
 
+    $exit_code = $PS_EXIT_PROG_ERROR unless defined $exit_code;
+
     carp($msg);
     if (defined $magic_id and not $no_update) {
Index: trunk/ippScripts/scripts/magic_process.pl
===================================================================
--- trunk/ippScripts/scripts/magic_process.pl	(revision 23294)
+++ trunk/ippScripts/scripts/magic_process.pl	(revision 23295)
@@ -332,4 +332,6 @@
     my $exit_code = shift;      # Exit code to add
 
+    $exit_code = $PS_EXIT_PROG_ERROR unless defined $exit_code;
+
     carp($msg);
     if (defined $magic_id and defined $node and not $no_update) {
Index: trunk/ippScripts/scripts/magic_tree.pl
===================================================================
--- trunk/ippScripts/scripts/magic_tree.pl	(revision 23294)
+++ trunk/ippScripts/scripts/magic_tree.pl	(revision 23295)
@@ -290,4 +290,6 @@
     my $exit_code = shift;      # Exit code to add
 
+    $exit_code = $PS_EXIT_PROG_ERROR unless defined $exit_code;
+
     carp($msg);
     if (defined $magic_id and not $no_update) {
Index: trunk/ippScripts/scripts/register_exp.pl
===================================================================
--- trunk/ippScripts/scripts/register_exp.pl	(revision 23294)
+++ trunk/ippScripts/scripts/register_exp.pl	(revision 23295)
@@ -187,4 +187,6 @@
     my $exit_code = shift;
 
+    $exit_code = $PS_EXIT_PROG_ERROR unless defined $exit_code;
+
     carp($msg);
     if (defined $exp_id and not $no_update) {
Index: trunk/ippScripts/scripts/register_imfile.pl
===================================================================
--- trunk/ippScripts/scripts/register_imfile.pl	(revision 23294)
+++ trunk/ippScripts/scripts/register_imfile.pl	(revision 23295)
@@ -94,5 +94,5 @@
     print "STDOUT:\n$out1";
     print "STDERR:\n$err1";
-    &my_die("Unable to perform ppStats on exposure id $exp_id: " . $h1->result(), $exp_id, $tmp_exp_name, $tmp_class_id, $uri, $h1->result() ) unless $result1;
+    &my_die("Unable to perform ppStats on exposure id $exp_id: " . $h1->result(), $exp_id, $tmp_exp_name, $tmp_class_id, $uri, ($h1->result() or $PS_EXIT_PROG_ERROR) ) unless $result1;
 
     print "[Running " . join(' ', @command2) . "]\n";
@@ -103,5 +103,5 @@
     print "STDOUT:\n$out2";
     print "STDERR:\n$err2";
-    &my_die("Unable to perform ppStatsFromMetadata on exposure id $exp_id: " . $h2->result(), $exp_id, $tmp_exp_name, $tmp_class_id, $uri, $h2->result() ) unless $result2;
+    &my_die("Unable to perform ppStatsFromMetadata on exposure id $exp_id: " . $h2->result(), $exp_id, $tmp_exp_name, $tmp_class_id, $uri, ($h2->result() or $PS_EXIT_PROG_ERROR) ) unless $result2;
     chomp $out2;
     $cmdflags = $out2;
@@ -128,10 +128,10 @@
 
 # determine solar-system parameters
-my $longitude = &value_for_flag ($cmdflags, "-longitude");
-my $latitude  = &value_for_flag ($cmdflags, "-latitude");
-my $elevation = &value_for_flag ($cmdflags, "-elevation");
-my $ra        = &value_for_flag ($cmdflags, "-ra");
-my $dec       = &value_for_flag ($cmdflags, "-decl");
-my $dateobs   = &value_for_flag ($cmdflags, "-dateobs");
+my $longitude = &value_for_flag($cmdflags, "-longitude");
+my $latitude  = &value_for_flag($cmdflags, "-latitude");
+my $elevation = &value_for_flag($cmdflags, "-elevation");
+my $ra        = &value_for_flag($cmdflags, "-ra");
+my $dec       = &value_for_flag($cmdflags, "-decl");
+my $dateobs   = &value_for_flag($cmdflags, "-dateobs");
 
 # if the needed data is available, pass it to sunmoon:
@@ -212,4 +212,6 @@
 
     # for failed imfiles, we insert UNKNOWN for inst, telescope, class_id
+
+    $exit_code = $PS_EXIT_PROG_ERROR unless defined $exit_code;
 
     carp($msg);
Index: trunk/ippScripts/scripts/stack_skycell.pl
===================================================================
--- trunk/ippScripts/scripts/stack_skycell.pl	(revision 23294)
+++ trunk/ippScripts/scripts/stack_skycell.pl	(revision 23295)
@@ -296,4 +296,6 @@
     my $exit_code = shift;      # Exit code to add
 
+    $exit_code = $PS_EXIT_PROG_ERROR unless defined $exit_code;
+
     carp($msg);
 
Index: trunk/ippScripts/scripts/summit_copy.pl
===================================================================
--- trunk/ippScripts/scripts/summit_copy.pl	(revision 23294)
+++ trunk/ippScripts/scripts/summit_copy.pl	(revision 23295)
@@ -136,4 +136,6 @@
     my $exit_code = shift; # Exit code to add
 
+    $exit_code = $PS_EXIT_PROG_ERROR unless defined $exit_code;
+
     warn $msg;
     unless ($no_update) {
Index: trunk/ippScripts/scripts/warp_overlap.pl
===================================================================
--- trunk/ippScripts/scripts/warp_overlap.pl	(revision 23294)
+++ trunk/ippScripts/scripts/warp_overlap.pl	(revision 23295)
@@ -186,4 +186,6 @@
     my $warp_id = shift;        # Warp identifier
     my $exit_code = shift;      # Exit code to add
+
+    $exit_code = $PS_EXIT_PROG_ERROR unless defined $exit_code;
 
     carp($msg);
Index: trunk/ippScripts/scripts/warp_skycell.pl
===================================================================
--- trunk/ippScripts/scripts/warp_skycell.pl	(revision 23294)
+++ trunk/ippScripts/scripts/warp_skycell.pl	(revision 23295)
@@ -288,4 +288,6 @@
     my $exit_code = shift;      # Exit code to add
 
+    $exit_code = $PS_EXIT_PROG_ERROR unless defined $exit_code;
+
     warn($msg);
     if (defined $warp_id and defined $skycell_id and defined $tess_dir and not $no_update) {
