Index: trunk/ippScripts/scripts/detrend_correct_imfile.pl
===================================================================
--- trunk/ippScripts/scripts/detrend_correct_imfile.pl	(revision 18020)
+++ trunk/ippScripts/scripts/detrend_correct_imfile.pl	(revision 18048)
@@ -25,5 +25,5 @@
 
 my ( $det_id, $exp_id, $class_id, $det_type, $exp_tag, $input_uri, $camera, $dbname, $workdir, $reduction,
-     $verbose, $no_update, $no_op );
+     $verbose, $no_update, $no_op, $outroot, $redirect, $corr_id, $corr_type, $corr_uri );
 GetOptions(
     'det_id|d=s'        => \$det_id,
@@ -41,4 +41,6 @@
     'no-update'         => \$no_update,
     'no-op'             => \$no_op,
+    'outroot'           => \$outroot,
+    'redirect-output'   => \$redirect,
 ) or pod2usage( 2 );
 
@@ -56,4 +58,11 @@
 # XXX this exits with status = 0 on failure
 $ipprc->define_camera($camera);
+
+if ($redirect) {
+    die "must suplly --outroot with --redirect-output" if !defined ($outroot);
+    my $logDest     = $ipprc->filename("LOG.IMFILE", $outroot, $class_id)
+       or &my_die("Missing entry from camera config", $det_id, $exp_id, $class_id, $PS_EXIT_CONFIG_ERROR);
+    $ipprc->redirect_output($logDest);
+}
 
 # Recipes to use as a function of detrend type
Index: trunk/ippScripts/scripts/detrend_norm_apply.pl
===================================================================
--- trunk/ippScripts/scripts/detrend_norm_apply.pl	(revision 18020)
+++ trunk/ippScripts/scripts/detrend_norm_apply.pl	(revision 18048)
@@ -26,5 +26,5 @@
 # Parse the command-line
 my ( $det_id, $iter, $class_id, $value, $input_uri, $camera, $det_type, $outroot, $dbname, $verbose,
-     $no_update, $no_op );
+     $no_update, $no_op, $redirect );
 GetOptions(
     'det_id|d=s'        => \$det_id,     # Detrend ID
@@ -40,4 +40,5 @@
     'no-update'         => \$no_update,  # Don't update the database
     'no-op'             => \$no_op,      # Don't do any operations
+    'redirect-output'   => \$redirect,   # send output from script to LOG.IMFILE
     ) or pod2usage( 2 );
 
@@ -56,4 +57,8 @@
 $ipprc->define_camera($camera);
 
+my $logDest = $ipprc->filename("LOG.IMFILE", $outroot, $class_id) 
+        or &my_die("Missing entry from camera config", $det_id, $iter, $class_id, $PS_EXIT_CONFIG_ERROR);
+$ipprc->redirect_output($logDest) if $redirect;
+
 my $RECIPE_PPIMAGE = 'PPIMAGE_N'; # Recipe to use with ppImage
 my $RECIPE_PPSTATS = 'CHIPSTATS'; # Recipe to use with ppStats
@@ -100,5 +105,4 @@
 my $statsName = $ipprc->filename("PPIMAGE.STATS", $outroot, $class_id) or &my_die("Missing entry from camera config", $det_id, $iter, $class_id, $PS_EXIT_CONFIG_ERROR);
 my $traceDest = $ipprc->filename("TRACE.IMFILE",  $outroot, $class_id) or &my_die("Missing entry from camera config", $det_id, $iter, $class_id, $PS_EXIT_CONFIG_ERROR);
-my $logDest   = $ipprc->filename("LOG.IMFILE",    $outroot, $class_id) or &my_die("Missing entry from camera config", $det_id, $iter, $class_id, $PS_EXIT_CONFIG_ERROR);
 
 # Run normalisation
Index: trunk/ippScripts/scripts/detrend_process_exp.pl
===================================================================
--- trunk/ippScripts/scripts/detrend_process_exp.pl	(revision 18020)
+++ trunk/ippScripts/scripts/detrend_process_exp.pl	(revision 18048)
@@ -27,5 +27,5 @@
 
 my ( $det_id, $exp_id, $det_type, $exp_tag, $camera, $outroot, $dbname, $reduction, $verbose, $no_update,
-     $no_op, $save_temps );
+     $no_op, $save_temps, $redirect );
 GetOptions(
     'det_id|d=s'        => \$det_id,
@@ -41,4 +41,5 @@
     'no-op'             => \$no_op,
     'save-temps'        => \$save_temps, # Save temporary files?
+    'redirect-output'   => \$redirect,
 ) or pod2usage( 2 );
 
@@ -54,4 +55,10 @@
 
 $ipprc->define_camera($camera);
+
+if ($redirect) {
+    my $logDest = $ipprc->filename("LOG.EXP", $outroot, "NONE") 
+        or &my_die("Missing entry in file rules", $det_id, $exp_id, $PS_EXIT_CONFIG_ERROR);
+    $ipprc->redirect_output($logDest);
+}
 
 # Recipes to use based on reduction class
Index: trunk/ippScripts/scripts/detrend_process_imfile.pl
===================================================================
--- trunk/ippScripts/scripts/detrend_process_imfile.pl	(revision 18020)
+++ trunk/ippScripts/scripts/detrend_process_imfile.pl	(revision 18048)
@@ -25,5 +25,5 @@
 
 my ( $det_id, $exp_id, $class_id, $det_type, $exp_tag, $input_uri, $camera, $outroot, $dbname, $reduction,
-     $verbose, $no_update, $no_op );
+     $verbose, $no_update, $no_op, $redirect );
 GetOptions(
     'det_id|d=s'        => \$det_id,
@@ -40,4 +40,5 @@
     'no-update'         => \$no_update,
     'no-op'             => \$no_op,
+    'redirect-output'   => \$redirect,
 ) or pod2usage( 2 );
 
@@ -56,4 +57,9 @@
 # XXX this exits with status = 0 on failure
 $ipprc->define_camera($camera);
+
+my $logDest     = $ipprc->filename("LOG.IMFILE",     $outroot, $class_id)
+      or &my_die("Missing entry from camera config", $exp_id, $exp_id, $class_id, $PS_EXIT_CONFIG_ERROR);
+
+$ipprc->redirect_output($logDest) if $redirect;
 
 # Recipes to use as a function of detrend type
@@ -95,6 +101,4 @@
 my $outputStats = $ipprc->filename("PPIMAGE.STATS",  $outroot, $class_id) or &my_die("Missing entry from camera config", $det_id, $exp_id, $class_id, $PS_EXIT_PROG_ERROR);
 my $traceDest   = $ipprc->filename("TRACE.IMFILE",   $outroot, $class_id) or &my_die("Missing entry from camera config", $exp_id, $exp_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, $exp_id, $class_id, $PS_EXIT_CONFIG_ERROR);
-
 # Run ppImage
 unless ($no_op) {
Index: trunk/ippScripts/scripts/detrend_reject_imfile.pl
===================================================================
--- trunk/ippScripts/scripts/detrend_reject_imfile.pl	(revision 18020)
+++ trunk/ippScripts/scripts/detrend_reject_imfile.pl	(revision 18048)
@@ -36,5 +36,5 @@
 # parse the command-line options
 my ( $det_id, $iter, $exp_id, $exp_tag, $det_type, $camera, $filter, $reject, $outroot, $dbname, $reduction,
-     $verbose, $no_update, $no_op, $save_temps );
+     $verbose, $no_update, $no_op, $save_temps, $redirect );
 GetOptions(
            'det_id|d=s'        => \$det_id,
@@ -53,4 +53,5 @@
            'no-op'             => \$no_op,
            'save-temps'        => \$save_temps, # Save temporary files?
+           'redirect-output'   => \$redirect,   # redirect output from LOG.IMFILE
            ) or pod2usage( 2 );
 
@@ -68,4 +69,12 @@
 # load IPP config information for the specified camera
 $ipprc->define_camera($camera);
+if ($redirect) {
+    # XXX should this really be going to LOG.IMFILE?
+    # That's where detrend.resid.pro was sending it
+    my $logDest     = $ipprc->filename("LOG.IMFILE", $outroot, "NONE")
+       or &my_die("Missing entry from camera config", $det_id, $iter, $exp_id, $PS_EXIT_CONFIG_ERROR);
+    $ipprc->redirect_output($logDest);
+}
+
 
 # Recipes to use based on reduction class
Index: trunk/ippScripts/scripts/detrend_resid.pl
===================================================================
--- trunk/ippScripts/scripts/detrend_resid.pl	(revision 18020)
+++ trunk/ippScripts/scripts/detrend_resid.pl	(revision 18048)
@@ -25,5 +25,5 @@
 
 my ( $det_id, $iter, $exp_id, $exp_tag, $class_id, $det_type, $detrend, $input_uri, $camera, $mode, $outroot,
-     $dbname, $reduction, $verbose, $no_update, $no_op );
+     $dbname, $reduction, $verbose, $no_update, $no_op, $redirect );
 GetOptions(
     'det_id|d=s'        => \$det_id,
@@ -43,4 +43,5 @@
     'no-update'         => \$no_update,
     'no-op'             => \$no_op,
+    'redirect-output'   => \$redirect,
 ) or pod2usage( 2 );
 
@@ -61,4 +62,8 @@
 
 $ipprc->define_camera($camera);
+my $logDest     = $ipprc->filename("LOG.IMFILE", $outroot, $class_id);
+if ($redirect) {
+    $ipprc->redirect_output($logDest);
+}
 
 # Recipes to use as a function of detrend type and mode
@@ -137,5 +142,4 @@
 my $outputStats = $ipprc->filename("PPIMAGE.STATS",  $outroot, $class_id);
 my $traceDest   = $ipprc->filename("TRACE.IMFILE",   $outroot, $class_id);
-my $logDest     = $ipprc->filename("LOG.IMFILE",     $outroot, $class_id);
 
 # Run ppImage & ppStats
Index: trunk/ippScripts/scripts/detrend_stack.pl
===================================================================
--- trunk/ippScripts/scripts/detrend_stack.pl	(revision 18020)
+++ 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
