Index: trunk/ippScripts/scripts/chip_imfile.pl
===================================================================
--- trunk/ippScripts/scripts/chip_imfile.pl	(revision 17671)
+++ trunk/ippScripts/scripts/chip_imfile.pl	(revision 17803)
@@ -28,21 +28,21 @@
      $no_update, $no_op );
 GetOptions(
-	   'exp_id=s'      => \$exp_id,    # Exposure identifier
-	   'exp_tag=s'     => \$exp_tag,   # Exposure identifier
-	   'chip_id=s'     => \$chip_id,   # Chiptool identifier
-	   'class_id=s'    => \$class_id,  # Class identifier
-	   'uri|u=s'       => \$uri,       # Input FITS file
-	   'camera|c=s'    => \$camera,	   # Camera
-	   'outroot|w=s'   => \$outroot,   # output file base name
-	   'dbname|d=s'    => \$dbname,    # Database name
-	   'reduction=s'   => \$reduction, # Reduction class
-	   'verbose'       => \$verbose,   # Print to stdout
-	   'no-update'     => \$no_update, # Don't update the database?
-	   'no-op'         => \$no_op,	   # Don't do any operations?
-	   ) or pod2usage( 2 );
+           'exp_id=s'      => \$exp_id,    # Exposure identifier
+           'exp_tag=s'     => \$exp_tag,   # Exposure identifier
+           'chip_id=s'     => \$chip_id,   # Chiptool identifier
+           'class_id=s'    => \$class_id,  # Class identifier
+           'uri|u=s'       => \$uri,       # Input FITS file
+           'camera|c=s'    => \$camera,    # Camera
+           'outroot|w=s'   => \$outroot,   # output file base name
+           'dbname|d=s'    => \$dbname,    # Database name
+           'reduction=s'   => \$reduction, # Reduction class
+           'verbose'       => \$verbose,   # Print to stdout
+           'no-update'     => \$no_update, # Don't update the database?
+           'no-op'         => \$no_op,     # Don't do any operations?
+           ) or pod2usage( 2 );
 
 pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV;
 pod2usage( -msg => "Required options: --exp_id --exp_tag --chip_id --class_id --uri --camera --outroot",
-	   -exitval => 3) unless
+           -exitval => 3) unless
     defined $exp_id and
     defined $exp_tag and
@@ -74,5 +74,5 @@
        { name => "ROBUST_MEDIAN",  type => "stdev", flag => "-bg_mean_stdev",  dtype => "float" },
        { name => "ROBUST_STDEV",   type => "rms",   flag => "-bg_stdev",       dtype => "float" },
-       { name => "OVER_VAL",       type => "mean",  flag => "-bias", 	       dtype => "float" },
+       { name => "OVER_VAL",       type => "mean",  flag => "-bias",           dtype => "float" },
        { name => "OVER_VAL",       type => "stdev", flag => "-bias_stdev",     dtype => "float" },
        { name => "FRINGE_0",       type => "rms",   flag => "-fringe_0",       dtype => "float" },
@@ -107,5 +107,5 @@
 }
 
-my $mdcParser = PS::IPP::Metadata::Config->new;	# Parser for metadata config files
+my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files
 
 &my_die("Couldn't find input file: $uri\n", $exp_id, $chip_id, $class_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($uri);
@@ -124,8 +124,8 @@
 my $outputWeight  = $ipprc->filename("PPIMAGE.CHIP.WEIGHT", $outroot, $class_id) or &my_die("Missing entry from camera config", $exp_id, $chip_id, $class_id, $PS_EXIT_CONFIG_ERROR);
 my $outputBin1    = $ipprc->filename("PPIMAGE.BIN1",        $outroot, $class_id) or &my_die("Missing entry from camera config", $exp_id, $chip_id, $class_id, $PS_EXIT_CONFIG_ERROR);
-my $outputBin2    = $ipprc->filename("PPIMAGE.BIN2",  	    $outroot, $class_id) or &my_die("Missing entry from camera config", $exp_id, $chip_id, $class_id, $PS_EXIT_CONFIG_ERROR);
-my $outputStats   = $ipprc->filename("PPIMAGE.STATS", 	    $outroot, $class_id) or &my_die("Missing entry from camera config", $exp_id, $chip_id, $class_id, $PS_EXIT_CONFIG_ERROR);
-my $traceDest     = $ipprc->filename("TRACE.IMFILE", 	    $outroot, $class_id) or &my_die("Missing entry from camera config", $exp_id, $chip_id, $class_id, $PS_EXIT_CONFIG_ERROR);
-my $logDest       = $ipprc->filename("LOG.IMFILE", 	    $outroot, $class_id) or &my_die("Missing entry from camera config", $exp_id, $chip_id, $class_id, $PS_EXIT_CONFIG_ERROR);
+my $outputBin2    = $ipprc->filename("PPIMAGE.BIN2",        $outroot, $class_id) or &my_die("Missing entry from camera config", $exp_id, $chip_id, $class_id, $PS_EXIT_CONFIG_ERROR);
+my $outputStats   = $ipprc->filename("PPIMAGE.STATS",       $outroot, $class_id) or &my_die("Missing entry from camera config", $exp_id, $chip_id, $class_id, $PS_EXIT_CONFIG_ERROR);
+my $traceDest     = $ipprc->filename("TRACE.IMFILE",        $outroot, $class_id) or &my_die("Missing entry from camera config", $exp_id, $chip_id, $class_id, $PS_EXIT_CONFIG_ERROR);
+my $logDest       = $ipprc->filename("LOG.IMFILE",          $outroot, $class_id) or &my_die("Missing entry from camera config", $exp_id, $chip_id, $class_id, $PS_EXIT_CONFIG_ERROR);
 
 # Run ppImage
@@ -141,8 +141,8 @@
 
     my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
-	run(command => $command, verbose => $verbose);
+        run(command => $command, verbose => $verbose);
     unless ($success) {
-	$error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
-	&my_die("Unable to perform ppImage: $error_code", $exp_id, $chip_id, $class_id, $error_code);
+        $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
+        &my_die("Unable to perform ppImage: $error_code", $exp_id, $chip_id, $class_id, $error_code);
     }
 
@@ -150,26 +150,26 @@
     $command = "$ppConfigDump -camera $camera -dump-recipe PPIMAGE -recipe PPIMAGE $recipe -";
     ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
-	run(command => $command, verbose => $verbose);
+        run(command => $command, verbose => $verbose);
     unless ($success) {
-	$error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
-	&my_die("Unable to perform ppConfigDump: $error_code", $exp_id, $chip_id, $class_id, $PS_EXIT_SYS_ERROR);
+        $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
+        &my_die("Unable to perform ppConfigDump: $error_code", $exp_id, $chip_id, $class_id, $PS_EXIT_SYS_ERROR);
     }
     my $recipeData = $mdcParser->parse(join "", @$stdout_buf) or
-	&my_die("Unable to parse metadata config doc", $exp_id, $chip_id, $class_id, $PS_EXIT_SYS_ERROR);
+        &my_die("Unable to parse metadata config doc", $exp_id, $chip_id, $class_id, $PS_EXIT_SYS_ERROR);
 
     ## allow the output images to be optional, depending on the recipe / reduction class
     my $outputImageExpect = metadataLookupBool($recipeData, 'CHIP.FITS');
     if ($outputImageExpect) {
-	&my_die("Couldn't find expected output file: $outputImage\n",  $exp_id, $chip_id, $class_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputImage);
+        &my_die("Couldn't find expected output file: $outputImage\n",  $exp_id, $chip_id, $class_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputImage);
     }
 
     my $outputMaskExpect = metadataLookupBool($recipeData, 'CHIP.MASK.FITS');
     if ($outputMaskExpect) {
-	&my_die("Couldn't find expected output file: $outputMask\n",   $exp_id, $chip_id, $class_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputMask);
+        &my_die("Couldn't find expected output file: $outputMask\n",   $exp_id, $chip_id, $class_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputMask);
     }
 
     my $outputWeightExpect = metadataLookupBool($recipeData, 'CHIP.WEIGHT.FITS');
     if ($outputWeightExpect) {
-	&my_die("Couldn't find expected output file: $outputWeight\n", $exp_id, $chip_id, $class_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputWeight);
+        &my_die("Couldn't find expected output file: $outputWeight\n", $exp_id, $chip_id, $class_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputWeight);
     }
 
@@ -179,5 +179,5 @@
 
     # Get the statistics on the processed image
-    my $statsFile;		# File handle
+    my $statsFile;              # File handle
     open $statsFile, $ipprc->file_resolve($outputStats) or &my_die("Can't open statistics file $outputStats: $!", $exp_id, $chip_id, $class_id, $PS_EXIT_SYS_ERROR);
     my @contents = <$statsFile>; # Contents of file
@@ -185,13 +185,13 @@
 
     # parse the statistics MDC file
-    my $mdcParser = PS::IPP::Metadata::Config->new();	# Parser for metadata config files
+    my $mdcParser = PS::IPP::Metadata::Config->new();   # Parser for metadata config files
     my $metadata = $mdcParser->parse(join "", @contents);
     unless ($metadata) {
-	&my_die("Unable to parse metadata config doc", $exp_id, $chip_id, $class_id, $PS_EXIT_PROG_ERROR);
+        &my_die("Unable to parse metadata config doc", $exp_id, $chip_id, $class_id, $PS_EXIT_PROG_ERROR);
     }
 
     # extract the stats from the metadata
     unless ($stats->parse($metadata)) {
-	&my_die("Failure extracting metadata from the statistics output file.\n", $exp_id, $chip_id, $class_id, $PS_EXIT_PROG_ERROR);
+        &my_die("Failure extracting metadata from the statistics output file.\n", $exp_id, $chip_id, $class_id, $PS_EXIT_PROG_ERROR);
     }
 }
@@ -204,4 +204,5 @@
 $command .= " -uri $outputImage";
 $command .= " -path_base $outroot";
+$command .= " -hostname $host" if defined $host;
 $command .= " -dbname $dbname" if defined $dbname;
 $command .= $stats->cmdflags();
@@ -210,9 +211,9 @@
 unless ($no_update) {
     my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
-	run(command => $command, verbose => $verbose);
+        run(command => $command, verbose => $verbose);
     unless ($success) {
-	$error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
-	warn("Unable to perform chiptool -addprocessedimfile: $error_code\n");
-	exit($error_code);
+        $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
+        warn("Unable to perform chiptool -addprocessedimfile: $error_code\n");
+        exit($error_code);
     }
 } else {
@@ -230,11 +231,12 @@
     carp($msg);
     if (defined $chip_id and defined $class_id and not $no_update) {
-	my $command = "$chiptool -addprocessedimfile";
-	$command .= " -exp_id $exp_id";
-	$command .= " -chip_id $chip_id";
-	$command .= " -class_id $class_id";
-	$command .= " -code $exit_code";
-	$command .= " -uri $outputImage";
-	$command .= " -dbname $dbname" if defined $dbname;
+        my $command = "$chiptool -addprocessedimfile";
+        $command .= " -exp_id $exp_id";
+        $command .= " -chip_id $chip_id";
+        $command .= " -class_id $class_id";
+        $command .= " -code $exit_code";
+        $command .= " -uri $outputImage";
+        $command .= " -hostname $host" if defined $host;
+        $command .= " -dbname $dbname" if defined $dbname;
         system ($command);
     }
