Index: /trunk/ippScripts/scripts/detrend_process_imfile.pl
===================================================================
--- /trunk/ippScripts/scripts/detrend_process_imfile.pl	(revision 9165)
+++ /trunk/ippScripts/scripts/detrend_process_imfile.pl	(revision 9166)
@@ -10,4 +10,8 @@
 use PS::IPP::Metadata::Config;
 use PS::IPP::Metadata::Stats;
+
+use PS::IPP::Config;
+my $ipprc = PS::IPP::Config->new(); # IPP configuration
+use File::Spec;
 
 use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt );
@@ -42,6 +46,4 @@
 };
 
-use constant DELETE_STATS => 0;	# Delete the statistics file when done?
-
 # Look for programs we need
 my $missing_tools;
@@ -55,8 +57,10 @@
 
 ### Output file name --- must match camera configuration!
-my $outputRoot =  $exp_tag . '.detproc.' . $det_id;
-my $outputName = $outputRoot . '.' . $class_id ;
-my $outputImage = $outputName . '.fits';
-my $outputStats = $outputName . '.stats';
+my ($vol, $dir, $file) = File::Spec->splitpath( $input_uri );
+my $outputRoot = $exp_tag . '.detproc.' . $det_id; # Root name
+$outputRoot = File::Spec->rel2abs( File::Spec->catpath( $vol, $dir, $outputRoot ), $ipprc->workdir() );
+$input_uri = File::Spec->rel2abs( $input_uri, $ipprc->workdir() );
+my $outputImage = $outputRoot . '.' . $class_id . '.fits';
+my $outputStats = $outputRoot . '.' . $class_id . '.stats';
 
 # Run ppImage
@@ -85,4 +89,7 @@
 }
 
+# Take off the absolute path, to stuff into the database
+$outputImage = File::Spec->abs2rel( $outputImage, $ipprc->workdir() );
+
 # Add the processed file to the database
 unless ($no_update) {
@@ -102,7 +109,8 @@
     die "Unable to perform dettool -addprocessedimfile for $det_id/$exp_tag/$class_id: $error_code\n"
 	if not $success;
+
+    unlink $outputStats;
 }
 
-unlink "$outputStats" if DELETE_STATS;
 
 __END__
Index: /trunk/ippScripts/scripts/phase0_imfile.pl
===================================================================
--- /trunk/ippScripts/scripts/phase0_imfile.pl	(revision 9165)
+++ /trunk/ippScripts/scripts/phase0_imfile.pl	(revision 9166)
@@ -11,4 +11,8 @@
 use PS::IPP::Metadata::Stats;
 use Data::Dumper;
+
+use PS::IPP::Config;
+my $ipprc = PS::IPP::Config->new(); # IPP configuration
+use File::Spec;
 
 use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt );
@@ -31,7 +35,4 @@
     and defined $class_id 
     and defined $uri;
-
-# XXX the uri should be processed either here or by ppImage
-my $file = $uri;
 
 use constant RECIPE => "PPSTATS_PHASE0"; # Recipe to use for ppStats
@@ -72,8 +73,11 @@
 die "Can't find required tools.\n" if $missing_tools;
 
+# Resolve the input URI
+$uri = File::Spec->rel2abs( $uri, $ipprc->workdir() );
+
 # Run ppStats on the input file
 my $stats;
 {
-    my $command = "$ppStats $file -recipe PPSTATS " . RECIPE; # Command to run ppStats
+    my $command = "$ppStats $uri -recipe PPSTATS " . RECIPE; # Command to run ppStats
     my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
         run(command => $command, verbose => 1);
