Index: trunk/ippScripts/scripts/background_chip.pl
===================================================================
--- trunk/ippScripts/scripts/background_chip.pl	(revision 35118)
+++ trunk/ippScripts/scripts/background_chip.pl	(revision 35154)
@@ -43,5 +43,5 @@
 # Parse the command-line arguments
 my ( $chip_bg_id, $class_id, $camera, $outroot, $dbname, $reduction, $verbose,
-     $threads, $no_update, $save_temps, $no_op, $redirect, $chip_path_base, $magicked );
+     $threads, $no_update, $save_temps, $no_op, $redirect, $chip_path_base, $cam_path_base, $magicked );
 GetOptions(
     'chip_bg_id=s'      => \$chip_bg_id,    # chipBackgroundRun identifier
@@ -53,4 +53,5 @@
     'threads=s'         => \$threads,   # Number of threads to use
     'chip_path_base=s'  => \$chip_path_base, # optional chip_path_base
+    'cam_path_base=s'   => \$cam_path_base, # optional camera stage path_base
     'magicked=s'        => \$magicked,  # magicked status of input
     'verbose'           => \$verbose,   # Print to stdout
@@ -94,4 +95,6 @@
 my $dump_config;
 if ($chip_path_base and $no_update) {
+    # XXX: this path through the code has not been excercized in awhile and probably does not work
+
     # we are running outside of a chip_bg_run (perhaps by the postage stamp server) don't dump config
     # or do stats. Get path to input from command line.
@@ -119,9 +122,15 @@
     my $input = $$inputs[0];    # Input of interest
     $in_path = $input->{path_base};
+    $cam_path_base = $input->{cam_path_base};
     $magicked = $input->{magicked};
 }
 
 my $in_image = $ipprc->filename("PPIMAGE.CHIP", $in_path, $class_id);
-my $in_mask = $ipprc->filename("PPIMAGE.CHIP.MASK", $in_path, $class_id);
+my $in_mask;
+if ($cam_path_base) {
+    $in_mask = $ipprc->filename("PSASTRO.OUTPUT.MASK", $cam_path_base, $class_id);
+} else {
+    $in_mask = $ipprc->filename("PPIMAGE.CHIP.MASK", $in_path, $class_id);
+}
 my $in_wt = $ipprc->filename("PPIMAGE.CHIP.VARIANCE", $in_path, $class_id);
 my $in_bg = $ipprc->filename("PSPHOT.BACKMDL", $in_path, $class_id);
@@ -177,4 +186,6 @@
 
 my $apply_auxiliary_mask = 1;
+# XXX Temporary lookup of auxiliary mask file from static location.
+# At some point I'll convert this to register the masks in the database and use detselect
 if ($apply_auxiliary_mask) {
     my @auxmask_start_date = qw(
@@ -238,5 +249,4 @@
     print "Auxililary mask file is $auxmask\n";
 }
-    
 
 
@@ -272,5 +282,6 @@
     &my_die("Couldn't find expected output file: $out_stats", $chip_bg_id, $class_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($out_stats);
 
-    my $command = "$ppStatsFromMetadata $out_stats - BACKGROUND_CHIP";
+    my $resolved_stats = $ipprc->file_resolve($out_stats);
+    my $command = "$ppStatsFromMetadata $resolved_stats - BACKGROUND_CHIP";
     my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
         run(command => $command, verbose => $verbose);
