Index: trunk/ippScripts/scripts/detrend_stack.pl
===================================================================
--- trunk/ippScripts/scripts/detrend_stack.pl	(revision 17941)
+++ trunk/ippScripts/scripts/detrend_stack.pl	(revision 18048)
@@ -18,5 +18,4 @@
 use PS::IPP::Metadata::Stats;
 use PS::IPP::Metadata::List qw( parse_md_list );
-use File::Temp qw( tempfile );
 use PS::IPP::Config 1.01 qw( :standard );
 
@@ -27,5 +26,5 @@
 
 my ( $det_id, $iter, $class_id, $det_type, $camera, $outroot, $dbname, $reduction, $verbose, $save_temps,
-     $no_update, $no_op );
+     $no_update, $no_op, $redirect );
 GetOptions(
     'det_id|d=s'        => \$det_id,
@@ -35,5 +34,5 @@
     'camera|c=s'        => \$camera,
     'outroot|w=s'       => \$outroot,   # output file base name
-    'dbname|d=s'        => \$dbname, # Database name
+    'dbname|d=s'        => \$dbname,    # Database name
     'reduction=s'       => \$reduction, # Reduction class for processing
     'verbose'           => \$verbose,   # Print to stdout
@@ -41,5 +40,7 @@
     'no-update'         => \$no_update,
     'no-op'             => \$no_op,
+    'redirect-output'   => \$redirect,
 ) or pod2usage( 2 );
+
 
 pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV;
@@ -55,4 +56,10 @@
 $ipprc->define_camera($camera);
 $det_type = uc($det_type);
+
+my $logDest = $ipprc->filename("LOG.IMFILE", $outroot, $class_id)
+    or &my_die("Missing entry in file rules", $det_id, $iter, $class_id, $PS_EXIT_CONFIG_ERROR);
+
+# optionally redirect the outputs from this script to LOG.IMFILE
+$ipprc->redirect_output($logDest) if $redirect;
 
 # Recipes to use as a function of detrend type
@@ -121,5 +128,6 @@
 
 # Generate MDC file with the inputs
-my ($listFile, $listName) = tempfile( $ipprc->file_resolve("$outroot.$class_id.list.XXXX"), UNLINK => !$save_temps );
+my ($listFile, $listName) = $ipprc->create_temp_file("$outroot.$class_id.list", $save_temps);
+
 my $num = 0;
 foreach my $file (@$files) {
@@ -161,5 +169,4 @@
 my $outputStats = $ipprc->filename("PPIMAGE.STATS",  $outroot, $class_id) or &my_die("Missing entry in file rules", $det_id, $iter, $class_id, $PS_EXIT_CONFIG_ERROR); # Statistics name
 my $traceDest   = $ipprc->filename("TRACE.IMFILE",   $outroot, $class_id) or &my_die("Missing entry in file rules", $det_id, $iter, $class_id, $PS_EXIT_CONFIG_ERROR); # Trace messages
-my $logDest     = $ipprc->filename("LOG.IMFILE",     $outroot, $class_id) or &my_die("Missing entry in file rules", $det_id, $iter, $class_id, $PS_EXIT_CONFIG_ERROR); # Log messages
 
 $command = "$ppMerge $listName $outroot"; # Command to run
