Index: trunk/ippScripts/scripts/detrend_process_imfile.pl
===================================================================
--- trunk/ippScripts/scripts/detrend_process_imfile.pl	(revision 17671)
+++ trunk/ippScripts/scripts/detrend_process_imfile.pl	(revision 17941)
@@ -36,5 +36,5 @@
     'outroot|w=s'       => \$outroot, # output file base name
     'dbname|d=s'        => \$dbname, # Database name
-    'reduction=s'       => \$reduction,	# Reduction class
+    'reduction=s'       => \$reduction, # Reduction class
     'verbose'           => \$verbose,   # Print to stdout
     'no-update'         => \$no_update,
@@ -44,12 +44,12 @@
 pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV;
 pod2usage( -msg => "Required options: --det_id --exp_id --class_id --det_type --exp_tag --input_uri --camera --outroot",
-	   -exitval => 3) unless 
+           -exitval => 3) unless
     defined $det_id    and
-    defined $exp_id    and 
-    defined $class_id  and 
-    defined $det_type  and 
-    defined $exp_tag   and 
-    defined $input_uri and 
-    defined $camera    and 
+    defined $exp_id    and
+    defined $class_id  and
+    defined $det_type  and
+    defined $exp_tag   and
+    defined $input_uri and
+    defined $camera    and
     defined $outroot;
 
@@ -62,6 +62,6 @@
 
 # values to extract from output metadata and the stats to calculate
-my $STATS = 
-   [   
+my $STATS =
+   [
        #          PPSTATS KEYWORD         STATISTIC          CHIPTOOL FLAG
        { name => "ROBUST_MEDIAN",  type => "mean",  flag => "-bg",            dtype => "float" },
@@ -75,7 +75,7 @@
 my $dettool = can_run('dettool') or (warn "Can't find dettool" and $missing_tools = 1);
 my $ppImage = can_run('ppImage') or (warn "Can't find ppImage" and $missing_tools = 1);
-if ($missing_tools) { 
+if ($missing_tools) {
     warn("Can't find required tools.");
-    exit($PS_EXIT_CONFIG_ERROR); 
+    exit($PS_EXIT_CONFIG_ERROR);
 }
 $ppImage .= " -dbname $dbname" if defined $dbname;
@@ -105,10 +105,11 @@
     $command .= " -stats $outputStats";
     $command .= " -tracedest $traceDest -log $logDest";
+    $command .= " -dbname $dbname" if defined $dbname;
 
     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", $det_id, $exp_id, $class_id, $error_code);
+        $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
+        &my_die("Unable to perform ppImage: $error_code", $det_id, $exp_id, $class_id, $error_code);
     }
 
@@ -119,5 +120,5 @@
 
     # Get the statistics on the processed image
-    my $statsFile;		# File handle
+    my $statsFile;              # File handle
     open $statsFile, $ipprc->file_resolve("$outputStats") or die "Can't open statistics file $outputStats: $!\n";
     my @contents = <$statsFile>; # Contents of file
@@ -125,5 +126,5 @@
 
     # 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)
         or &my_die("Unable to parse metadata config", $det_id, $exp_id, $class_id, $PS_EXIT_PROG_ERROR);
@@ -146,9 +147,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 dettool -addprocessedimfile: $error_code\n");
-	exit($error_code);
+        $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
+        warn("Unable to perform dettool -addprocessedimfile: $error_code\n");
+        exit($error_code);
     }
 } else {
@@ -159,5 +160,5 @@
 {
     my $msg = shift; # Warning message on die
-    my $det_id = shift;		# Detrend identifier
+    my $det_id = shift;         # Detrend identifier
     my $exp_id = shift; # Exposure tag
     my $class_id = shift; # Class identifier
@@ -166,10 +167,10 @@
     carp($msg);
     if (defined $det_id and defined $exp_id and defined $class_id and not $no_update) {
-	my $command = "$dettool -addprocessedimfile";
-	$command .= " -det_id $det_id";
-	$command .= " -exp_id $exp_id"; 
-	$command .= " -class_id $class_id";
-	$command .= " -code $exit_code";
-	$command .= " -dbname $dbname" if defined $dbname;
+        my $command = "$dettool -addprocessedimfile";
+        $command .= " -det_id $det_id";
+        $command .= " -exp_id $exp_id";
+        $command .= " -class_id $class_id";
+        $command .= " -code $exit_code";
+        $command .= " -dbname $dbname" if defined $dbname;
         system ($command);
     }
