Index: /trunk/ippScripts/scripts/camera_exp.pl
===================================================================
--- /trunk/ippScripts/scripts/camera_exp.pl	(revision 13274)
+++ /trunk/ippScripts/scripts/camera_exp.pl	(revision 13275)
@@ -17,16 +17,16 @@
 use PS::IPP::Metadata::List qw( parse_md_list );
 use Statistics::Descriptive;
-
-use PS::IPP::Config qw(
-    $PS_EXIT_SUCCESS
-    $PS_EXIT_UNKNOWN_ERROR
-    $PS_EXIT_SYS_ERROR
-    $PS_EXIT_CONFIG_ERROR
-    $PS_EXIT_PROG_ERROR
-    $PS_EXIT_DATA_ERROR
-    $PS_EXIT_TIMEOUT_ERROR
-    );
+use File::Temp qw( tempfile );
+
+use PS::IPP::Config qw($PS_EXIT_SUCCESS
+		       $PS_EXIT_UNKNOWN_ERROR
+		       $PS_EXIT_SYS_ERROR
+		       $PS_EXIT_CONFIG_ERROR
+		       $PS_EXIT_PROG_ERROR
+		       $PS_EXIT_DATA_ERROR
+		       $PS_EXIT_TIMEOUT_ERROR
+		       caturi
+		       );
 my $ipprc = PS::IPP::Config->new(); # IPP configuration
-use File::Spec;
 
 use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt );
@@ -125,41 +125,19 @@
 }
 
-# Set output directory
-if (defined $workdir) {
-    $workdir = $ipprc->convert_filename_absolute( $workdir );
-    $workdir = File::Spec->catdir( $workdir, $exp_id );
-} else {
-    my $example = $ipprc->convert_filename_absolute( ${$files}[0]->{path_base}) ; # Example original name
-    my ($vol, $dir, $file) = File::Spec->splitpath( $example );
-    $workdir = $dir;
-}
-system "mkdir -p $workdir" unless -d $workdir;
-
-# Generate the file list, and get the statistics
-my $outputFile =  "$exp_id.cam$cam_id";
-my $outputRoot = File::Spec->catfile( $workdir, $outputFile );
-
-my $list1Name = $outputRoot . '.b1.list'; # Name for the input file list for binning 1
-my $list2Name = $outputRoot . '.b2.list'; # Name for the input file list for binning 2
-my $list3Name = $outputRoot . '.b3.list'; # Name for the input file list for chip astrometry
+my ($list1File, $list1Name) = tempfile( "$exp_id.cam$cam_id.b1.list.XXXX", UNLINK => 1 ); # For binning 1
+my ($list2File, $list2Name) = tempfile( "$exp_id.cam$cam_id.b2.list.XXXX", UNLINK => 1 ); # For binning 2
+my ($list3File, $list3Name) = tempfile( "$exp_id.cam$cam_id.b3.list.XXXX", UNLINK => 1 ); # For astrometry
 
 my @means;			# Array of means
 my @stdevs;			# Array of stdevs
-open my $list1File, '>' . $list1Name;
-open my $list2File, '>' . $list2Name;
-open my $list3File, '>' . $list3Name;
-
-print "$list1Name $list2Name $list3Name\n";
-
 my $chipObjects; 
 foreach my $file (@$files) {
     # use the path_base as OUTPUT root and convert the filenames with ipprc->filename:
     my $class_id = $file->{class_id};
-    my $origRoot = $ipprc->convert_filename_absolute( $file->{path_base} ); # Original root name
-
-    # if there is only one chip, we use this name for the input to addstar
-    $chipObjects = $ipprc->filename("PSASTRO.OUTPUT", $origRoot, $class_id);
-    print $list1File $ipprc->filename("PPIMAGE.BIN1", $origRoot, $class_id);
-    print $list2File $ipprc->filename("PPIMAGE.BIN2", $origRoot, $class_id);
+
+    # If there is only one chip, we use this name for the input to addstar
+    $chipObjects = $ipprc->filename("PSASTRO.OUTPUT", $file->{path_base}, $class_id);
+    print $list1File $ipprc->filename("PPIMAGE.BIN1", $file->{path_base}, $class_id);
+    print $list2File $ipprc->filename("PPIMAGE.BIN2", $file->{path_base}, $class_id);
     print $list3File $chipObjects;
     push @means, $file->{bg};
@@ -170,9 +148,10 @@
 close $list3File;
 
-# Output products --- need to synch with the camera configuration!
+# Output products
+$workdir = caturi( $workdir, $exp_id ) if defined $workdir;
+my $outputRoot = $ipprc->file_prepare( "$exp_id.cam$cam_id", $workdir, ${$files}[0]->{path_base} );
 my $jpeg1 = $ipprc->filename("PPIMAGE.JPEG1", $outputRoot); # Binned JPEG #1
 my $jpeg2 = $ipprc->filename("PPIMAGE.JPEG2", $outputRoot); # Binned JPEG #2
 my $fpaObjects = $ipprc->filename("PSASTRO.OUTPUT", $outputRoot); # MEF psastro output
-# my $dvo_camera = $ipprc->dvocamera();
 
 unless ($no_op) {
@@ -188,8 +167,8 @@
 	    &my_die("Unable to perform psastro: $error_code", $cam_id, $error_code);
 	}
-	&my_die("Unable to find expected output file: $fpaObjects", $cam_id, $PS_EXIT_PROG_ERROR) unless -f $fpaObjects;
     } else {
-	system "cp $chipObjects $fpaObjects";
-    }
+	$ipprc->file_copy($chipObjects, $fpaObjects);
+    }
+    &my_die("Unable to find expected output file: $fpaObjects", $cam_id, $PS_EXIT_PROG_ERROR) unless -f $ipprc->file_resolve($fpaObjects);
 
     # run addstar on either the single chip output or the single fpa output
@@ -197,5 +176,5 @@
     # XXX which in turn points at ippconfig/dvo.site
     {
-	my $command = "addstar -D CAMERA $camera $fpaObjects";
+	my $command = "addstar -D CAMERA $camera " . $ipprc->file_resolve($fpaObjects);
 	my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
 	    run(command => $command, verbose => 1);
@@ -215,5 +194,5 @@
 	    &my_die("Unable to perform ppImage: $error_code", $cam_id, $error_code);
 	}
-	&my_die("Unable to find expected output file: $jpeg1", $cam_id, $PS_EXIT_PROG_ERROR) unless -f $jpeg1;
+	&my_die("Unable to find expected output file: $jpeg1", $cam_id, $PS_EXIT_PROG_ERROR) unless -f $ipprc->file_resolve($jpeg1);
     }
 
@@ -227,12 +206,9 @@
 	    &my_die("Unable to perform ppImage: $error_code", $cam_id, $error_code);
 	}
-	&my_die("Unable to find expected output file: $jpeg2", $cam_id, $PS_EXIT_PROG_ERROR) unless -f $jpeg2;
-    }
-}
-
-# XXX keep the same outroot as the input
+	&my_die("Unable to find expected output file: $jpeg2", $cam_id, $PS_EXIT_PROG_ERROR) unless -f $ipprc->file_resolve($jpeg2);
+    }
+}
+
 # Add the result into the database
-$outputRoot = $ipprc->convert_filename_relative( $outputRoot );
-
 unless ($no_update) {
     my $command = "$camtool -addprocessedexp -cam_id $cam_id -uri UNKNOWN -path_base $outputRoot " .
@@ -247,7 +223,4 @@
 	exit($error_code);
     }
-
-    unlink $list1Name;
-    unlink $list2Name;
 }
 
Index: /trunk/ippScripts/scripts/chip_imfile.pl
===================================================================
--- /trunk/ippScripts/scripts/chip_imfile.pl	(revision 13274)
+++ /trunk/ippScripts/scripts/chip_imfile.pl	(revision 13275)
@@ -14,15 +14,14 @@
 use PS::IPP::Metadata::Stats;
 use Data::Dumper;
-use PS::IPP::Config qw(
-    $PS_EXIT_SUCCESS
-    $PS_EXIT_UNKNOWN_ERROR
-    $PS_EXIT_SYS_ERROR
-    $PS_EXIT_CONFIG_ERROR
-    $PS_EXIT_PROG_ERROR
-    $PS_EXIT_DATA_ERROR
-    $PS_EXIT_TIMEOUT_ERROR
-    );
+use PS::IPP::Config qw($PS_EXIT_SUCCESS
+		       $PS_EXIT_UNKNOWN_ERROR
+		       $PS_EXIT_SYS_ERROR
+		       $PS_EXIT_CONFIG_ERROR
+		       $PS_EXIT_PROG_ERROR
+		       $PS_EXIT_DATA_ERROR
+		       $PS_EXIT_TIMEOUT_ERROR
+		       caturi
+		       );
 my $ipprc = PS::IPP::Config->new(); # IPP configuration
-use File::Spec;
 
 use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt );
@@ -78,19 +77,8 @@
 $ppImage .= " -dbname $dbname" if defined $dbname;
 
-$input = $ipprc->convert_filename_absolute( $input );
 
-# Set output directory
-if (defined $workdir) {
-    $workdir = $ipprc->convert_filename_absolute( $workdir );
-    $workdir = File::Spec->catdir( $workdir, $exp_id );
-} else {
-    my ($vol, $dir, $file) = File::Spec->splitpath( $input );
-    $workdir = $dir;
-}
-system "mkdir -p $workdir" unless -d $workdir;
+$workdir = caturi( $workdir, $exp_id ) if defined $workdir;
 
-### Output file name --- must match camera configuration!
-my $outputFile =  "$exp_id.chp$chip_id";
-my $outputRoot = File::Spec->catfile( $workdir, $outputFile );
+my $outputRoot = $ipprc->file_prepare( "$exp_id.chp$chip_id", $workdir, $input );
 my $outputImage = $ipprc->filename("PPIMAGE.OUTPUT", $outputRoot, $class_id);
 my $outputBin1 = $ipprc->filename("PPIMAGE.BIN1", $outputRoot, $class_id);
@@ -104,5 +92,5 @@
     print "outputBin1: $outputBin1\n";
     print "outputStats: $outputStats\n";
-    
+
     my $command = "$ppImage -file $input $outputRoot -recipe PPIMAGE " . RECIPE .
 	" -stat $outputStats"; # Command to run ppImage
@@ -113,12 +101,12 @@
 	&my_die("Unable to perform ppImage: $error_code", $chip_id, $class_id, $error_code);
     }
-    &my_die("Couldn't find expected output file: $outputImage\n", $chip_id, $class_id, $PS_EXIT_SYS_ERROR) unless -f $outputImage;
-    &my_die("Couldn't find expected output file: $outputBin1\n", $chip_id, $class_id, $PS_EXIT_SYS_ERROR) unless -f $outputBin1;
-    &my_die("Couldn't find expected output file: $outputBin2\n", $chip_id, $class_id, $PS_EXIT_SYS_ERROR) unless -f $outputBin2;
-    &my_die("Couldn't find expected output file: $outputStats\n", $chip_id, $class_id, $PS_EXIT_SYS_ERROR) unless -f $outputStats;
+    &my_die("Couldn't find expected output file: $outputImage\n", $chip_id, $class_id, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($outputImage);
+    &my_die("Couldn't find expected output file: $outputBin1\n", $chip_id, $class_id, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($outputBin1);
+    &my_die("Couldn't find expected output file: $outputBin2\n", $chip_id, $class_id, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($outputBin2);
+    &my_die("Couldn't find expected output file: $outputStats\n", $chip_id, $class_id, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($outputStats);
 
     # Get the statistics on the processed image
     my $statsFile;		# File handle
-    open $statsFile, $outputStats or &my_die("Can't open statistics file $outputStats: $!", $chip_id, $class_id, $PS_EXIT_SYS_ERROR);
+    open $statsFile, $ipprc->file_resolve($outputStats) or &my_die("Can't open statistics file $outputStats: $!", $chip_id, $class_id, $PS_EXIT_SYS_ERROR);
     my @contents = <$statsFile>; # Contents of file
     close $statsFile;
@@ -131,7 +119,4 @@
 
 # Add the processed file to the database
-$outputImage = $ipprc->convert_filename_relative( $outputImage);
-$outputRoot  = $ipprc->convert_filename_relative( $outputRoot );
-
 my $bg = ($stats->bg_mean() or 'NAN');
 my $bg_stdev = ($stats->bg_stdev() or 'NAN');
@@ -155,6 +140,4 @@
 	exit($error_code);
     }
-
-    unlink $outputStats;
 }
 
Index: /trunk/ippScripts/scripts/detrend_norm_apply.pl
===================================================================
--- /trunk/ippScripts/scripts/detrend_norm_apply.pl	(revision 13274)
+++ /trunk/ippScripts/scripts/detrend_norm_apply.pl	(revision 13275)
@@ -14,15 +14,14 @@
 use Data::Dumper;
 
-use PS::IPP::Config qw(
-    $PS_EXIT_SUCCESS
-    $PS_EXIT_UNKNOWN_ERROR
-    $PS_EXIT_SYS_ERROR
-    $PS_EXIT_CONFIG_ERROR
-    $PS_EXIT_PROG_ERROR
-    $PS_EXIT_DATA_ERROR
-    $PS_EXIT_TIMEOUT_ERROR
-    );
+use PS::IPP::Config qw($PS_EXIT_SUCCESS
+		       $PS_EXIT_UNKNOWN_ERROR
+		       $PS_EXIT_SYS_ERROR
+		       $PS_EXIT_CONFIG_ERROR
+		       $PS_EXIT_PROG_ERROR
+		       $PS_EXIT_DATA_ERROR
+		       $PS_EXIT_TIMEOUT_ERROR
+		       caturi
+		       );
 my $ipprc = PS::IPP::Config->new(); # IPP configuration
-use File::Spec;
 
 use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt );
@@ -82,25 +81,10 @@
 }
 
-$input = $ipprc->convert_filename_absolute( $input );
+$workdir = caturi( $workdir, "$camera.$det_type.$det_id" ) if defined $workdir;
 
-# Set output directory
-if (defined $workdir) {
-    $workdir = $ipprc->convert_filename_absolute( $workdir );
-    my $subdir = "$camera.$det_type.$det_id";
-    $workdir = File::Spec->catdir( $workdir, $subdir );
-} else {
-    my ($vol, $dir, $file) = File::Spec->splitpath( $input );
-    $workdir = $dir;
-}
-system "mkdir -p $workdir" unless -d $workdir;
-
-# Output name
-my $outputFile = "$camera.$det_type.norm.$det_id.$iter"; # Root name
-my $outputRoot = File::Spec->catfile( $workdir, $outputFile );
-
+my $outputRoot = $ipprc->file_prepare( "$camera.$det_type.norm.$det_id.$iter", $workdir, $input );
 my $output = $ipprc->filename("PPIMAGE.OUTPUT", $outputRoot, $class_id);
 my $b1name = $ipprc->filename("PPIMAGE.BIN1", $outputRoot, $class_id);
 my $b2name = $ipprc->filename("PPIMAGE.BIN2", $outputRoot, $class_id);
-
 my $statsName = $outputRoot . '.' . $class_id . '.stats'; # Statistics file
 
@@ -116,12 +100,13 @@
 	&my_die("Unable to perform ppImage: $error_code", $det_id, $iter, $class_id, $error_code);
     }
-    &my_die("Can't find expected output file: $output", $det_id, $iter, $class_id, $PS_EXIT_SYS_ERROR) unless -e $output;
-    &my_die("Can't find expected output file: $b1name", $det_id, $iter, $class_id, $PS_EXIT_SYS_ERROR) unless -e $b1name;
-    &my_die("Can't find expected output file: $b2name", $det_id, $iter, $class_id, $PS_EXIT_SYS_ERROR) unless -e $b2name;
-    &my_die("Can't find expected output file: $statsName", $det_id, $iter, $class_id, $PS_EXIT_SYS_ERROR) unless -e $statsName;
+    &my_die("Can't find expected output file: $output", $det_id, $iter, $class_id, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($output);
+    &my_die("Can't find expected output file: $b1name", $det_id, $iter, $class_id, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($b1name);
+    &my_die("Can't find expected output file: $b2name", $det_id, $iter, $class_id, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($b2name);
+    &my_die("Can't find expected output file: $statsName", $det_id, $iter, $class_id, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($statsName);
     
     # Get the statistics on the normalised image
-    my $statsFile;		# File handle
-    open $statsFile, $statsName or &my_die("Can't open statistics file $statsName: $!\n", $det_id, $iter, $class_id, $PS_EXIT_SYS_ERROR);
+    my $statsFile; # File handle
+    open $statsFile, $ipprc->file_resolve($statsName) or &my_die("Can't open statistics file $statsName: $!\n", $det_id, $iter, $class_id, $PS_EXIT_SYS_ERROR);
+    &my_die("Can't open statistics file $statsName: $!\n", $det_id, $iter, $class_id, $PS_EXIT_SYS_ERROR) unless defined $statsFile;
     my @contents = <$statsFile>; # Contents of file
     close $statsFile;
@@ -130,10 +115,7 @@
 	or &my_die("Unable to parse metadata config", $det_id, $iter, $class_id, $PS_EXIT_PROG_ERROR);
     $stats->parse($metadata) or &my_die("Unable to find all values in statistics output.", $det_id, $iter, $class_id, $PS_EXIT_PROG_ERROR);
-}    
+}
 
 # Update the database
-$output = $ipprc->convert_filename_relative( $output );
-$outputRoot = $ipprc->convert_filename_relative( $outputRoot );
-
 my $bg = ($stats->bg_mean() or 'NAN');
 my $bg_stdev = ($stats->bg_stdev() or 'NAN');
@@ -153,6 +135,4 @@
 	exit($error_code);
     }
-
-    unlink $statsName;
 }
 
Index: /trunk/ippScripts/scripts/detrend_norm_exp.pl
===================================================================
--- /trunk/ippScripts/scripts/detrend_norm_exp.pl	(revision 13274)
+++ /trunk/ippScripts/scripts/detrend_norm_exp.pl	(revision 13275)
@@ -17,16 +17,16 @@
 use PS::IPP::Metadata::List qw( parse_md_list );
 use Statistics::Descriptive;
+use File::Temp qw( tempfile );
 
-use PS::IPP::Config qw(
-    $PS_EXIT_SUCCESS
-    $PS_EXIT_UNKNOWN_ERROR
-    $PS_EXIT_SYS_ERROR
-    $PS_EXIT_CONFIG_ERROR
-    $PS_EXIT_PROG_ERROR
-    $PS_EXIT_DATA_ERROR
-    $PS_EXIT_TIMEOUT_ERROR
-    );
+use PS::IPP::Config qw($PS_EXIT_SUCCESS
+		       $PS_EXIT_UNKNOWN_ERROR
+		       $PS_EXIT_SYS_ERROR
+		       $PS_EXIT_CONFIG_ERROR
+		       $PS_EXIT_PROG_ERROR
+		       $PS_EXIT_DATA_ERROR
+		       $PS_EXIT_TIMEOUT_ERROR
+		       caturi
+		       );
 my $ipprc = PS::IPP::Config->new(); # IPP configuration
-use File::Spec;
 
 use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt );
@@ -115,30 +115,11 @@
 }
 
-# Set output directory
-if (defined $workdir) {
-    $workdir = $ipprc->convert_filename_absolute( $workdir );
-    my $subdir = "$camera.$det_type.$det_id";
-    $workdir = File::Spec->catdir( $workdir, $subdir );
-} else {
-    my $example = $ipprc->convert_filename_absolute( ${$files}[0]->{path_base} ); # Example file, for path
-    my ($vol, $dir, $file) = File::Spec->splitpath( $example );
-    $workdir = $dir;
-}
-system "mkdir -p $workdir" unless -d $workdir;
-
-# Generate the file list, and get the statistics
-my $outputFile = "$camera.$det_type.norm.$det_id.$iter"; # Root output name
-my $outputRoot = File::Spec->catfile( $workdir, $outputFile );
-
-my $list1Name = $outputRoot . '.b1.list'; # Name for the input file list for binning 1
-my $list2Name = $outputRoot . '.b2.list'; # Name for the input file list for binning 2
+my ($list1File, $list1Name) = tempfile( "$camera.$det_type.norm.$det_id.$iter.b1.list.XXXX", UNLINK => 1 );
+my ($list2File, $list2Name) = tempfile( "$camera.$det_type.norm.$det_id.$iter.b2.list.XXXX", UNLINK => 1 );
 my @means;			# Array of means
 my @stdevs;			# Array of stdevs
-open my $list1File, '>' . $list1Name;
-open my $list2File, '>' . $list2Name;
 foreach my $file (@$files) {
-    my $origRoot = $ipprc->convert_filename_absolute( $file->{path_base} ); # Original root name
-    print $list1File ( $ipprc->filename( "PPIMAGE.BIN1", $origRoot, $file->{class_id} ) . "\n");
-    print $list2File ( $ipprc->filename( "PPIMAGE.BIN2", $origRoot, $file->{class_id} ) . "\n");
+    print $list1File ( $ipprc->filename( "PPIMAGE.BIN1", $file->{path_base}, $file->{class_id} ) . "\n");
+    print $list2File ( $ipprc->filename( "PPIMAGE.BIN2", $file->{path_base}, $file->{class_id} ) . "\n");
     push @means, $file->{bg};
     push @stdevs, $file->{bg_stdev};
@@ -148,4 +129,6 @@
 
 # Output products
+$workdir = caturi( $workdir, "$camera.$det_type.$det_id" ) if defined $workdir;
+my $outputRoot = $ipprc->file_prepare( "$camera.$det_type.norm.$det_id.$iter", $workdir );
 my $jpeg1Name = $ipprc->filename("PPIMAGE.JPEG1", $outputRoot); # Binned JPEG #1
 my $jpeg2Name = $ipprc->filename("PPIMAGE.JPEG2", $outputRoot); # Binned JPEG #2
@@ -157,5 +140,5 @@
 	my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
 	    run(command => $command, verbose => 1);
-	&my_die("Unable to find expected output file: $jpeg1Name", $det_id, $iter, $PS_EXIT_SYS_ERROR) unless -f $jpeg1Name;
+	&my_die("Unable to find expected output file: $jpeg1Name", $det_id, $iter, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($jpeg1Name);
     }
     
@@ -165,10 +148,7 @@
 	my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
 	    run(command => $command, verbose => 1);
-	&my_die("Unable to find expected output file: $jpeg2Name", $det_id, $iter, $PS_EXIT_SYS_ERROR) unless -f $jpeg2Name;
+	&my_die("Unable to find expected output file: $jpeg2Name", $det_id, $iter, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($jpeg2Name);
     }
 }
-
-# Add the result into the database
-$outputRoot = $ipprc->convert_filename_relative( $outputRoot );
 
 unless ($no_update) {
@@ -183,7 +163,4 @@
 	&my_die("Unable to perform dettool -addnormalizedexp: $error_code", $det_id, $iter, $error_code);
     }
-
-    unlink $list1Name;
-    unlink $list2Name;
 }
 
Index: /trunk/ippScripts/scripts/detrend_process_exp.pl
===================================================================
--- /trunk/ippScripts/scripts/detrend_process_exp.pl	(revision 13274)
+++ /trunk/ippScripts/scripts/detrend_process_exp.pl	(revision 13275)
@@ -18,15 +18,15 @@
 use Statistics::Descriptive;
 
-use PS::IPP::Config qw(
-    $PS_EXIT_SUCCESS
-    $PS_EXIT_UNKNOWN_ERROR
-    $PS_EXIT_SYS_ERROR
-    $PS_EXIT_CONFIG_ERROR
-    $PS_EXIT_PROG_ERROR
-    $PS_EXIT_DATA_ERROR
-    $PS_EXIT_TIMEOUT_ERROR
-    );
+use PS::IPP::Config qw($PS_EXIT_SUCCESS
+		       $PS_EXIT_UNKNOWN_ERROR
+		       $PS_EXIT_SYS_ERROR
+		       $PS_EXIT_CONFIG_ERROR
+		       $PS_EXIT_PROG_ERROR
+		       $PS_EXIT_DATA_ERROR
+		       $PS_EXIT_TIMEOUT_ERROR
+		       caturi
+		       );
 my $ipprc = PS::IPP::Config->new(); # IPP configuration
-use File::Spec;
+use File::Temp qw( tempfile );
 
 use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt );
@@ -115,30 +115,12 @@
 }
 
-# Set output directory
-if (defined $workdir) {
-    $workdir = $ipprc->convert_filename_absolute( $workdir );
-    my $subdir = "$camera.$det_type.$det_id";
-    $workdir = File::Spec->catdir( $workdir, $subdir, $exp_tag );
-} else {
-    my $example = $ipprc->convert_filename_absolute( ${$files}[0]->{path_base} ); # Example original name
-    my ($vol, $dir, $file) = File::Spec->splitpath( $example );
-    $workdir = $dir;
-}
-system "mkdir -p $workdir" unless -d $workdir;
-
-my $outputFile = $exp_tag . '.detproc.' . $det_id; # Root name
-my $outputRoot = File::Spec->catfile( $workdir, $outputFile );
-
-# output files:
-my $list1Name = $outputRoot . '.b1.list'; # Name for the input file list for binning 1
-my $list2Name = $outputRoot . '.b2.list'; # Name for the input file list for binning 2
+# File lists for the two binnings
+my ($list1File, $list1Name) = tempfile( "$exp_tag.detproc.$det_id.b1.list.XXXX", UNLINK => 1 );
+my ($list2File, $list2Name) = tempfile( "$exp_tag.detproc.$det_id.b2.list.XXXX", UNLINK => 1 );
 my @means;			# Array of means
 my @stdevs;			# Array of stdevs
-open my $list1File, '>' . $list1Name;
-open my $list2File, '>' . $list2Name;
 foreach my $file (@$files) {
-    my $origRoot = $ipprc->convert_filename_absolute( $file->{path_base} ); # Original root name
-    print $list1File ($ipprc->filename( "PPIMAGE.BIN1", $origRoot, $file->{class_id} ) . "\n");
-    print $list2File ($ipprc->filename( "PPIMAGE.BIN2", $origRoot, $file->{class_id} ) . "\n");
+    print $list1File ($ipprc->filename( "PPIMAGE.BIN1", $file->{path_base}, $file->{class_id} ) . "\n");
+    print $list2File ($ipprc->filename( "PPIMAGE.BIN2", $file->{path_base}, $file->{class_id} ) . "\n");
     push @means, $file->{bg};
     push @stdevs, $file->{bg_stdev};
@@ -147,5 +129,7 @@
 close $list2File;
 
-# Output products
+# Output files
+$workdir = caturi( $workdir, "$camera.$det_type.$det_id" ) if defined $workdir;
+my $outputRoot = $ipprc->file_prepare( "$exp_tag.detproc.$det_id", $workdir, ${$files}[0]->{path_base} );
 my $jpeg1 = $ipprc->filename("PPIMAGE.JPEG1", $outputRoot); # Binned JPEG #1
 my $jpeg2 = $ipprc->filename("PPIMAGE.JPEG2", $outputRoot); # Binned JPEG #2
@@ -161,5 +145,5 @@
 	    &my_die("Unable to perform ppImage: $error_code", $det_id, $exp_tag, $error_code);
 	}
-	&my_die("Unable to find expected output file: $jpeg1", $det_id, $exp_tag, $PS_EXIT_SYS_ERROR) unless -f $jpeg1;
+	&my_die("Unable to find expected output file: $jpeg1", $det_id, $exp_tag, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($jpeg1);
     }
     
@@ -173,10 +157,7 @@
 	    &my_die("Unable to perform ppImage: $error_code", $det_id, $exp_tag, $error_code);
 	}
-	&my_die("Unable to find expected output file: $jpeg2", $det_id, $exp_tag, $PS_EXIT_SYS_ERROR) unless -f $jpeg2;
-    }
-}
-
-# Add the result into the database
-$outputRoot = $ipprc->convert_filename_relative( $outputRoot );
+	&my_die("Unable to find expected output file: $jpeg2", $det_id, $exp_tag, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($jpeg2);
+    }
+}
 
 unless ($no_update) {
@@ -192,7 +173,4 @@
 	exit($error_code);
     }
-
-    unlink $list1Name;
-    unlink $list2Name;
 }
 
Index: /trunk/ippScripts/scripts/detrend_process_imfile.pl
===================================================================
--- /trunk/ippScripts/scripts/detrend_process_imfile.pl	(revision 13274)
+++ /trunk/ippScripts/scripts/detrend_process_imfile.pl	(revision 13275)
@@ -17,15 +17,14 @@
 use PS::IPP::Metadata::Stats;
 
-use PS::IPP::Config qw(
-    $PS_EXIT_SUCCESS
-    $PS_EXIT_UNKNOWN_ERROR
-    $PS_EXIT_SYS_ERROR
-    $PS_EXIT_CONFIG_ERROR
-    $PS_EXIT_PROG_ERROR
-    $PS_EXIT_DATA_ERROR
-    $PS_EXIT_TIMEOUT_ERROR
-    );
+use PS::IPP::Config qw($PS_EXIT_SUCCESS
+		       $PS_EXIT_UNKNOWN_ERROR
+		       $PS_EXIT_SYS_ERROR
+		       $PS_EXIT_CONFIG_ERROR
+		       $PS_EXIT_PROG_ERROR
+		       $PS_EXIT_DATA_ERROR
+		       $PS_EXIT_TIMEOUT_ERROR
+		       caturi
+		       );
 my $ipprc = PS::IPP::Config->new(); # IPP configuration
-use File::Spec;
 
 use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt );
@@ -88,20 +87,7 @@
 }
 
-$input_uri = $ipprc->convert_filename_absolute( $input_uri );
+$workdir = caturi( $workdir, "$camera.$det_type.$det_id" ) if defined $workdir;
 
-# Set output directory
-if (defined $workdir) {
-    $workdir = $ipprc->convert_filename_absolute( $workdir );
-    my $subdir = "$camera.$det_type.$det_id";
-    $workdir = File::Spec->catdir( $workdir, $subdir, $exp_tag );
-} else {
-    my ($vol, $dir, $file) = File::Spec->splitpath( $input_uri );
-    $workdir = $dir;
-}
-system "mkdir -p $workdir" unless -d $workdir;
-
-# Output files
-my $outputFile = "$exp_tag.detproc.$det_id"; # Root name
-my $outputRoot = File::Spec->catfile( $workdir, $outputFile );
+my $outputRoot = $ipprc->file_prepare( "$exp_tag.detproc.$det_id", $workdir, $input_uri );
 my $outputImage = $ipprc->filename("PPIMAGE.OUTPUT", $outputRoot, $class_id);
 my $outputBin1 = $ipprc->filename("PPIMAGE.BIN1", $outputRoot, $class_id);
@@ -120,12 +106,12 @@
 	&my_die("Unable to perform ppImage: $error_code", $det_id, $exp_tag, $class_id, $error_code);
     }
-    &my_die("Couldn't find expected output file: $outputImage", $det_id, $exp_tag, $class_id, $PS_EXIT_SYS_ERROR) unless -f $outputImage;
-    &my_die("Couldn't find expected output file: $outputStats", $det_id, $exp_tag, $class_id, $PS_EXIT_SYS_ERROR) unless -f $outputStats;
-    &my_die("Couldn't find expected output file: $outputBin1", $det_id, $exp_tag, $class_id, $PS_EXIT_SYS_ERROR) unless -f $outputBin1;
-    &my_die("Couldn't find expected output file: $outputBin2", $det_id, $exp_tag, $class_id, $PS_EXIT_SYS_ERROR) unless -f $outputBin2;
+    &my_die("Couldn't find expected output file: $outputImage", $det_id, $exp_tag, $class_id, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($outputImage);
+    &my_die("Couldn't find expected output file: $outputStats", $det_id, $exp_tag, $class_id, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($outputStats);
+    &my_die("Couldn't find expected output file: $outputBin1", $det_id, $exp_tag, $class_id, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($outputBin1);
+    &my_die("Couldn't find expected output file: $outputBin2", $det_id, $exp_tag, $class_id, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($outputBin2);
 
     # Get the statistics on the processed image
     my $statsFile;		# File handle
-    open $statsFile, "$outputStats" or die "Can't open statistics file $outputStats: $!\n";
+    open $statsFile, $ipprc->file_resolve("$outputStats") or die "Can't open statistics file $outputStats: $!\n";
     my @contents = <$statsFile>; # Contents of file
     close $statsFile;
@@ -135,8 +121,4 @@
     $stats->parse($metadata) or &my_die("Unable to find all values in statistics output.", $det_id, $exp_tag, $class_id, $PS_EXIT_PROG_ERROR);
 }
-
-# Take off the absolute path, to stuff into the database
-$outputImage = $ipprc->convert_filename_relative( $outputImage );
-$outputRoot = $ipprc->convert_filename_relative( $outputRoot );
 
 my $bg = ($stats->bg_mean() or 'NAN');
@@ -158,6 +140,4 @@
 	exit($error_code);
     }
-
-    unlink $outputStats;
 }
 
Index: /trunk/ippScripts/scripts/detrend_reject_exp.pl
===================================================================
--- /trunk/ippScripts/scripts/detrend_reject_exp.pl	(revision 13274)
+++ /trunk/ippScripts/scripts/detrend_reject_exp.pl	(revision 13275)
@@ -17,15 +17,14 @@
 use PS::IPP::Metadata::List qw( parse_md_list );
 use Statistics::Descriptive;
-use File::Spec;
-
-use PS::IPP::Config qw(
-    $PS_EXIT_SUCCESS
-    $PS_EXIT_UNKNOWN_ERROR
-    $PS_EXIT_SYS_ERROR
-    $PS_EXIT_CONFIG_ERROR
-    $PS_EXIT_PROG_ERROR
-    $PS_EXIT_DATA_ERROR
-    $PS_EXIT_TIMEOUT_ERROR
-    );
+
+use PS::IPP::Config qw($PS_EXIT_SUCCESS
+		       $PS_EXIT_UNKNOWN_ERROR
+		       $PS_EXIT_SYS_ERROR
+		       $PS_EXIT_CONFIG_ERROR
+		       $PS_EXIT_PROG_ERROR
+		       $PS_EXIT_DATA_ERROR
+		       $PS_EXIT_TIMEOUT_ERROR
+		       caturi
+		       );
 my $ipprc = PS::IPP::Config->new(); # IPP configuration
 
@@ -122,15 +121,11 @@
 my $reject_meanstdev = rejection_limit( 'ENSEMBLE.MEANSTDEV', $det_type, $filter );
 
-my $logName = "$camera.$det_type.$det_id.$iter.detreject.log"; # Name for log
-if (defined $workdir) {
-    $workdir = $ipprc->convert_filename_absolute( $workdir );
-    my $subdir = "$camera.$det_type.$det_id";
-    $workdir = File::Spec->catdir( $workdir, $subdir );
-    system "mkdir -p $workdir" unless -d $workdir;
-    $logName = File::Spec->catfile( $workdir, $logName );
-}
+$workdir = caturi( $workdir, "$camera.$det_type.$det_id" ) if defined $workdir;
+
+my $logName = $ipprc->file_prepare( "$camera.$det_type.$det_id.$iter.detreject.log", $workdir ); # Name for log
+
 my $logFile;
 unless ($no_op) {
-    open $logFile, "> $logName" or &my_die("Unable to open log file $logName.\n", $det_id, $iter, $PS_EXIT_SYS_ERROR);
+    $logFile = $ipprc->file_create_open( $logName );
     print $logFile "Ensemble mean " . $meanStats->mean() . " +/- " . $meanStats->standard_deviation .
 	", stdev " . $stdevStats->mean() . " +/- " . $stdevStats->standard_deviation() . "\n\n";
Index: /trunk/ippScripts/scripts/detrend_reject_imfile.pl
===================================================================
--- /trunk/ippScripts/scripts/detrend_reject_imfile.pl	(revision 13274)
+++ /trunk/ippScripts/scripts/detrend_reject_imfile.pl	(revision 13275)
@@ -17,16 +17,16 @@
 use PS::IPP::Metadata::List qw( parse_md_list );
 use Statistics::Descriptive;
-
-use PS::IPP::Config qw(
-    $PS_EXIT_SUCCESS
-    $PS_EXIT_UNKNOWN_ERROR
-    $PS_EXIT_SYS_ERROR
-    $PS_EXIT_CONFIG_ERROR
-    $PS_EXIT_PROG_ERROR
-    $PS_EXIT_DATA_ERROR
-    $PS_EXIT_TIMEOUT_ERROR
-    );
+use File::Temp qw( tempfile );
+
+use PS::IPP::Config qw($PS_EXIT_SUCCESS
+		       $PS_EXIT_UNKNOWN_ERROR
+		       $PS_EXIT_SYS_ERROR
+		       $PS_EXIT_CONFIG_ERROR
+		       $PS_EXIT_PROG_ERROR
+		       $PS_EXIT_DATA_ERROR
+		       $PS_EXIT_TIMEOUT_ERROR
+		       caturi
+		       );
 my $ipprc = PS::IPP::Config->new(); # IPP configuration
-use File::Spec;
 
 use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt );
@@ -93,33 +93,14 @@
 }
 
-# Set output directory
-if (defined $workdir) {
-    $workdir = $ipprc->convert_filename_absolute( $workdir );
-    my $subdir = "$camera.$det_type.$det_id";
-    $workdir = File::Spec->catdir( $workdir, $subdir, $exp_tag );
-} else {
-    my $example = $ipprc->convert_filename_absolute( ${$files}[0]->{path_base} ); # Example original name
-    my ($vol, $dir, $file) = File::Spec->splitpath( $example );
-    $workdir = $dir;
-}
-system "mkdir -p $workdir" unless -d $workdir;
-
-# Generate the file list, and get the statistics
-my $outputFile = "$exp_tag.detresid.$det_id.$iter"; # Root name
-my $outputRoot = File::Spec->catfile( $workdir, $outputFile );
-
-my $list1Name = $outputRoot . '.b1.list'; # Name for the input file list for binning 1
-my $list2Name = $outputRoot . '.b2.list'; # Name for the input file list for binning 2
-
+
+my ($list1File, $list1Name) = tempfile( "$exp_tag.detresid.$det_id.$iter.b1.list.XXXX", UNLINK => 1 );
+my ($list2File, $list2Name) = tempfile( "$exp_tag.detresid.$det_id.$iter.b2.list.XXXX", UNLINK => 1 );
 my @means;			# Array of means
 my @variances;			# Array of variances
 my @meanStdevs;			# Array of mean stdevs
 my @names;			# Array of names (class_id)
-open my $list1File, '>' . $list1Name;
-open my $list2File, '>' . $list2Name;
 foreach my $file (@$files) {
-    my $origRoot = $ipprc->convert_filename_absolute( $file->{path_base} ); # Original root name
-    print $list1File ($ipprc->filename( "PPIMAGE.BIN1", $origRoot, $file->{class_id} ) . "\n");
-    print $list2File ($ipprc->filename( "PPIMAGE.BIN2", $origRoot, $file->{class_id} ) . "\n");
+    print $list1File ($ipprc->filename( "PPIMAGE.BIN1", $file->{path_base}, $file->{class_id} ) . "\n");
+    print $list2File ($ipprc->filename( "PPIMAGE.BIN2", $file->{path_base}, $file->{class_id} ) . "\n");
     push @means, $file->{bg};
     push @meanStdevs, $file->{bg_mean_stdev};
@@ -131,5 +112,7 @@
 close $list2File;
 
-# Output products --- need to synch with the camera configuration!
+# Output products
+$workdir = caturi( $workdir, "$camera.$det_type.$det_id" ) if defined $workdir;
+my $outputRoot = $ipprc->file_prepare( "$exp_tag.detresid.$det_id.$iter", $workdir, ${$files}[0]->{path_base} );
 my $jpeg1Name = $ipprc->filename("PPIMAGE.JPEG1", $outputRoot); # Binned JPEG #1
 my $jpeg2Name = $ipprc->filename("PPIMAGE.JPEG2", $outputRoot); # Binned JPEG #2
@@ -146,5 +129,5 @@
 	    &my_die("Unable to run ppImage: $error_code", $det_id, $iter, $exp_tag, $error_code);
 	}
-	&my_die("Unable to find expected output file: $jpeg1Name", $det_id, $iter, $exp_tag, $PS_EXIT_SYS_ERROR) unless -f $jpeg1Name;
+	&my_die("Unable to find expected output file: $jpeg1Name", $det_id, $iter, $exp_tag, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($jpeg1Name);
     }
     
@@ -158,5 +141,5 @@
 	    &my_die("Unable to run ppImage: $error_code", $det_id, $iter, $exp_tag, $error_code);
 	}
-	&my_die("Unable to find expected output file: $jpeg2Name", $det_id, $iter, $exp_tag, $PS_EXIT_SYS_ERROR) unless -f $jpeg2Name;
+	&my_die("Unable to find expected output file: $jpeg2Name", $det_id, $iter, $exp_tag, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($jpeg2Name);
     }
 }
@@ -173,9 +156,8 @@
 my $reject_exp_sn           = rejection_limit( 'EXP.SN',           $det_type, $filter );
 
-my $logName = "$exp_tag.detreject.$det_id.$iter.log"; # Name for log
-$logName = File::Spec->catfile( $workdir, $logName );
+my $logName = caturi( $workdir, "$exp_tag.detreject.$det_id.$iter.log" ); # Name for log
 my $logFile;
 unless ($no_op) {
-    open $logFile, "> $logName" or &my_die("Unable to open log file $logName", $det_id, $iter, $exp_tag, $PS_EXIT_SYS_ERROR);
+    $logFile = $ipprc->file_create_open( $logName );
 }
 
@@ -311,6 +293,4 @@
 
 # Add the result into the database
-$outputRoot = $ipprc->convert_filename_relative( $outputRoot );
-
 my $bg = $mean;
 my $bg_stdev = $stdev;
@@ -330,7 +310,4 @@
 	exit($error_code);
     }
-
-    unlink $list1Name;
-    unlink $list2Name;
 }
 
Index: /trunk/ippScripts/scripts/detrend_resid.pl
===================================================================
--- /trunk/ippScripts/scripts/detrend_resid.pl	(revision 13274)
+++ /trunk/ippScripts/scripts/detrend_resid.pl	(revision 13275)
@@ -18,15 +18,14 @@
 use Data::Dumper;
 
-use PS::IPP::Config qw(
-    $PS_EXIT_SUCCESS
-    $PS_EXIT_UNKNOWN_ERROR
-    $PS_EXIT_SYS_ERROR
-    $PS_EXIT_CONFIG_ERROR
-    $PS_EXIT_PROG_ERROR
-    $PS_EXIT_DATA_ERROR
-    $PS_EXIT_TIMEOUT_ERROR
-    );
+use PS::IPP::Config qw($PS_EXIT_SUCCESS
+		       $PS_EXIT_UNKNOWN_ERROR
+		       $PS_EXIT_SYS_ERROR
+		       $PS_EXIT_CONFIG_ERROR
+		       $PS_EXIT_PROG_ERROR
+		       $PS_EXIT_DATA_ERROR
+		       $PS_EXIT_TIMEOUT_ERROR
+		       caturi
+		       );
 my $ipprc = PS::IPP::Config->new(); # IPP configuration
-use File::Spec;
 
 use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt );
@@ -118,26 +117,11 @@
 &my_die("Unrecognised detrend type: $det_type", $det_id, $iter, $exp_tag, $class_id, $PS_EXIT_PROG_ERROR) unless defined $recipe;
 
-# Set output directory
-if (defined $workdir) {
-    $workdir = $ipprc->convert_filename_absolute( $workdir );
-    my $subdir = "$camera.$det_type.$det_id";
-    $workdir = File::Spec->catdir( $workdir, $subdir, $exp_tag );
-} else {
-    my ($vol, $dir, $file) = File::Spec->splitpath( $ipprc->convert_filename_absolute( $input_uri ) );
-    $workdir = $dir;
-}
-system "mkdir -p $workdir" unless -d $workdir;
-
-my $outputFile = "$exp_tag.detresid.$det_id.$iter"; # Root name
-my $outputRoot = File::Spec->catfile( $workdir, $outputFile );
-
+$workdir = caturi( $workdir, "$camera.$det_type.$det_id" ) if defined $workdir;
+
+my $outputRoot = $ipprc->file_prepare( "$exp_tag.detresid.$det_id.$iter", $workdir, $input_uri );
 my $outputName = $ipprc->filename("PPIMAGE.OUTPUT", $outputRoot, $class_id);
 my $bin1Name =  $ipprc->filename("PPIMAGE.BIN1", $outputRoot, $class_id);
 my $bin2Name =  $ipprc->filename("PPIMAGE.BIN2", $outputRoot, $class_id);
-
 my $outputStats = $outputRoot . '.' . $class_id . '.stats';
-
-$detrend = $ipprc->convert_filename_absolute( $detrend ) if defined $detrend;
-$input_uri = $ipprc->convert_filename_absolute( $input_uri );
 
 # Run ppImage
@@ -160,12 +144,12 @@
 	&my_die("Unable to perform ppImage: $error_code", $det_id, $iter, $exp_tag, $class_id, $error_code);
     }
-    &my_die("Couldn't find expected output file: $outputName", $det_id, $iter, $exp_tag, $class_id, $PS_EXIT_SYS_ERROR) unless -f $outputName;
-    &my_die("Couldn't find expected output file: $outputStats", $det_id, $iter, $exp_tag, $class_id, $PS_EXIT_SYS_ERROR) unless -f $outputStats;
-    &my_die("Couldn't find expected output file: $bin1Name", $det_id, $iter, $exp_tag, $class_id, $PS_EXIT_SYS_ERROR) unless -f $bin1Name;
-    &my_die("Couldn't find expected output file: $bin2Name", $det_id, $iter, $exp_tag, $class_id, $PS_EXIT_SYS_ERROR) unless -f $bin2Name;
+    &my_die("Couldn't find expected output file: $outputName", $det_id, $iter, $exp_tag, $class_id, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($outputName);
+    &my_die("Couldn't find expected output file: $outputStats", $det_id, $iter, $exp_tag, $class_id, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($outputStats);
+    &my_die("Couldn't find expected output file: $bin1Name", $det_id, $iter, $exp_tag, $class_id, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($bin1Name);
+    &my_die("Couldn't find expected output file: $bin2Name", $det_id, $iter, $exp_tag, $class_id, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($bin2Name);
 
     # Get the statistics on the residual image
     my $statsFile;		# File handle
-    open $statsFile, $outputStats or &my_die("Can't open statistics file $outputStats: $!", $det_id, $iter, $exp_tag, $class_id, $PS_EXIT_SYS_ERROR);
+    open $statsFile, $ipprc->file_resolve($outputStats) or &my_die("Can't open statistics file $outputStats: $!", $det_id, $iter, $exp_tag, $class_id, $PS_EXIT_SYS_ERROR);
     my @contents = <$statsFile>; # Contents of file
     close $statsFile;
@@ -178,7 +162,4 @@
 
 # Add the processed file to the database
-$outputName = $ipprc->convert_filename_relative( $outputName );
-$outputRoot = $ipprc->convert_filename_relative( $outputRoot );
-
 my $bg = ($stats->bg_mean() or 'NAN');
 my $bg_stdev = ($stats->bg_stdev() or 'NAN');
@@ -198,6 +179,4 @@
 	exit($error_code);
     }
-
-    unlink $outputStats;    
 }
 
Index: /trunk/ippScripts/scripts/detrend_stack.pl
===================================================================
--- /trunk/ippScripts/scripts/detrend_stack.pl	(revision 13274)
+++ /trunk/ippScripts/scripts/detrend_stack.pl	(revision 13275)
@@ -18,15 +18,14 @@
 use PS::IPP::Metadata::Stats;
 
-use PS::IPP::Config qw(
-    $PS_EXIT_SUCCESS
-    $PS_EXIT_UNKNOWN_ERROR
-    $PS_EXIT_SYS_ERROR
-    $PS_EXIT_CONFIG_ERROR
-    $PS_EXIT_PROG_ERROR
-    $PS_EXIT_DATA_ERROR
-    $PS_EXIT_TIMEOUT_ERROR
-    );
+use PS::IPP::Config qw($PS_EXIT_SUCCESS
+		       $PS_EXIT_UNKNOWN_ERROR
+		       $PS_EXIT_SYS_ERROR
+		       $PS_EXIT_CONFIG_ERROR
+		       $PS_EXIT_PROG_ERROR
+		       $PS_EXIT_DATA_ERROR
+		       $PS_EXIT_TIMEOUT_ERROR
+		       caturi
+		       );
 my $ipprc = PS::IPP::Config->new(); # IPP configuration
-use File::Spec;
 
 use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt );
@@ -98,29 +97,16 @@
 }
 
-# Set output directory
-if (defined $workdir) {
-    $workdir = $ipprc->convert_filename_absolute( $workdir );
-    my $subdir = "$camera.$det_type.$det_id";
-    $workdir = File::Spec->catdir( $workdir, $subdir );
-} else {
-    my $example = $ipprc->convert_filename_absolute( ${$files}[0]->{uri} ); # Example file
-    my ($vol, $dir, $file) = File::Spec->splitpath( $example );
-    $workdir = $dir;
-}
-system "mkdir -p $workdir" unless -d $workdir;
+$workdir = caturi( $workdir, "$camera.$det_type.$det_id" ) if defined $workdir;
 
-# Stack the files
-my $outputFile = "$camera.$det_type.$det_id.$iter.$class_id"; # Root name
-my $outputRoot = File::Spec->catfile( $workdir, $outputFile );
+my $outputRoot = $ipprc->file_prepare( "$camera.$det_type.$det_id.$iter.$class_id", $workdir, ${$files}[0]->{uri} );
 my $outputStack = $outputRoot . '.fits'; # Output name
 my $outputStats = $outputRoot . '.stats'; # Statistics name
 
+# Stack the files
 my $stats = PS::IPP::Metadata::Stats->new(); # Stats parser
 unless ($no_op) {
     my $command = "$ppMerge $outputStack"; # Command to run
     foreach my $file (@$files) {
-	my $uri = $file->{uri};	# URI for input file
-	$uri = $ipprc->convert_filename_absolute($uri);
-	$command .= ' ' . $uri;
+	$command .= ' ' . $file->{uri};
     }
     $command .= " -recipe PPMERGE $recipe";
@@ -134,9 +120,9 @@
 	&my_die("Unable to perform ppMerge: $error_code", $det_id, $iter, $class_id, $error_code);
     }
-    &my_die("Unable to find expected output file: $outputStack\n", $det_id, $iter, $class_id, $PS_EXIT_SYS_ERROR) unless -f $outputStack;
-    &my_die("Unable to find expected output file: $outputStats\n", $det_id, $iter, $class_id, $PS_EXIT_SYS_ERROR) unless -f $outputStats;
+    &my_die("Unable to find expected output file: $outputStack\n", $det_id, $iter, $class_id, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($outputStack);
+    &my_die("Unable to find expected output file: $outputStats\n", $det_id, $iter, $class_id, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($outputStats);
 
     # Get the statistics on the stacked image
-    open(my $statsFile, "$outputStats") or
+    open(my $statsFile, $ipprc->file_resolve("$outputStats")) or
 	&my_die("Can't open statistics file $outputStats: $!", $det_id, $iter, $class_id, $PS_EXIT_SYS_ERROR);
     my $contents = do { local $/; <$statsFile> }; # Contents of file
@@ -156,5 +142,4 @@
 
 # Add the resultant into the database
-$outputStack = $ipprc->convert_filename_relative($outputStack);
 unless ($no_update) {
     my $command = "$dettool -addstacked -det_id $det_id -iteration $iter -class_id $class_id" .
@@ -170,6 +155,4 @@
 	exit($error_code);
     }
-
-    unlink $outputStats;
 }
 
Index: /trunk/ippScripts/scripts/diff_skycell.pl
===================================================================
--- /trunk/ippScripts/scripts/diff_skycell.pl	(revision 13274)
+++ /trunk/ippScripts/scripts/diff_skycell.pl	(revision 13275)
@@ -19,15 +19,14 @@
 use Data::Dumper;
 
-use PS::IPP::Config qw(
-    $PS_EXIT_SUCCESS
-    $PS_EXIT_UNKNOWN_ERROR
-    $PS_EXIT_SYS_ERROR
-    $PS_EXIT_CONFIG_ERROR
-    $PS_EXIT_PROG_ERROR
-    $PS_EXIT_DATA_ERROR
-    $PS_EXIT_TIMEOUT_ERROR
-    );
+use PS::IPP::Config qw($PS_EXIT_SUCCESS
+		       $PS_EXIT_UNKNOWN_ERROR
+		       $PS_EXIT_SYS_ERROR
+		       $PS_EXIT_CONFIG_ERROR
+		       $PS_EXIT_PROG_ERROR
+		       $PS_EXIT_DATA_ERROR
+		       $PS_EXIT_TIMEOUT_ERROR
+		       caturi
+		       );
 my $ipprc = PS::IPP::Config->new(); # IPP configuration
-use File::Spec;
 
 use constant POIS_OPTIONS => '-v -B 1000';
@@ -89,9 +88,8 @@
 my $camera;			# Camera
 foreach my $file (@$files) {
-    my $uri = $ipprc->convert_filename_absolute( $file->{uri} ); # URI for file
     if (defined $file->{template} and $file->{template}) {
-	$template = $uri;
-    } else {
-	$input = $uri;
+	$template = $file->{uri};
+    } else {
+	$input = $file->{uri};
     }
     if (defined $tess_id) {
@@ -119,18 +117,8 @@
 $ipprc->define_camera($camera);
 
-### Working directory
-if (defined $workdir) {
-    $workdir = $ipprc->convert_filename_absolute( $workdir );
-    $workdir = File::Spec->catdir( $workdir, "tess_" . $tess_id, "sky_" . $skycell_id );
-} else {
-    my ($vol, $dir, $file) = File::Spec->splitpath( $input );
-    $workdir = $dir;
-}
-system "mkdir -p $workdir" unless -d $workdir;
 
 # Get the output filenames
-my $outputFile = "$tess_id.$skycell_id.dif$diff_id"; # Root name
-my $outputRoot = File::Spec->catfile( $workdir, $outputFile );
-
+$workdir = caturi( $workdir, "tess_" . $tess_id, "sky_" . $skycell_id ) if defined $workdir;
+my $outputRoot = $ipprc->file_prepare( "$tess_id.$skycell_id.dif$diff_id", $workdir, $input );
 my $outputName = $outputRoot . ".fits";
 my $bin1Name =  $ipprc->filename("PPIMAGE.BIN1", $outputRoot);
@@ -138,8 +126,14 @@
 my $outputStats = $outputRoot . '.stats';
 
+
+### XXX We have to play around some here, because pois can't use Nebulous
+my $outputNameResolved = $ipprc->file_create( $outputName );
+my $templateResolved = $ipprc->file_resolve( $template );
+my $inputResolved = $ipprc->file_resolve( $input );
+
 # Perform subtraction
 my $stats = PS::IPP::Metadata::Stats->new(); # Stats parser
 unless ($no_op) {
-    my $command = "$pois " . POIS_OPTIONS() . " $template $input $outputName"; # Command to run pois
+    my $command = "$pois " . POIS_OPTIONS() . " $templateResolved $inputResolved $outputNameResolved"; # Command to run pois
 
     my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
@@ -149,13 +143,13 @@
 	&my_die("Unable to perform ppImage: $error_code", $diff_id, $error_code);
     }
-    &my_die("Couldn't find expected output file: $outputName", $diff_id, $PS_EXIT_SYS_ERROR) unless -f $outputName;
-#    &my_die("Couldn't find expected output file: $bin1Name",    $diff_id, $PS_EXIT_SYS_ERROR) unless -f $bin1Name;
-#    &my_die("Couldn't find expected output file: $bin2Name",    $diff_id, $PS_EXIT_SYS_ERROR) unless -f $bin2Name;
-#    &my_die("Couldn't find expected output file: $outputStats", $diff_id, $PS_EXIT_SYS_ERROR) unless -f $outputStats;
+    &my_die("Couldn't find expected output file: $outputName", $diff_id, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($outputName);
+#    &my_die("Couldn't find expected output file: $bin1Name",    $diff_id, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($bin1Name);
+#    &my_die("Couldn't find expected output file: $bin2Name",    $diff_id, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($bin2Name);
+#    &my_die("Couldn't find expected output file: $outputStats", $diff_id, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($outputStats);
 
     # Get the statistics on the residual image
     if (0) { ### Disabled because pois doesn't output stats yet
 	my $statsFile;		# File handle
-	open $statsFile, $outputStats or &my_die("Can't open statistics file $outputStats: $!", $diff_id, $PS_EXIT_SYS_ERROR);
+	open $statsFile, $ipprc->file_resolve($outputStats) or &my_die("Can't open statistics file $outputStats: $!", $diff_id, $PS_EXIT_SYS_ERROR);
 	my @contents = <$statsFile>; # Contents of file
 	close $statsFile;
@@ -167,7 +161,4 @@
 
 # Add the processed file to the database
-$outputName = $ipprc->convert_filename_relative( $outputName );
-$outputRoot = $ipprc->convert_filename_relative( $outputRoot );
-
 my $bg = ($stats->bg_mean() or 'NAN');
 my $bg_stdev = ($stats->bg_stdev() or 'NAN');
@@ -187,6 +178,4 @@
 	    &my_die("Unable to perform difftool -adddiffskyfile: $error_code", $diff_id, $error_code);
 	}
-	
-#	unlink $outputStats;    
     }
 
Index: /trunk/ippScripts/scripts/ipp_datapath.pl
===================================================================
--- /trunk/ippScripts/scripts/ipp_datapath.pl	(revision 13274)
+++ /trunk/ippScripts/scripts/ipp_datapath.pl	(revision 13275)
@@ -9,5 +9,5 @@
 die "No filename specified.\n" if scalar @ARGV != 1;
 
-print $ipprc->convert_filename_absolute(shift @ARGV) . "\n";
+print $ipprc->file_resolve(shift @ARGV) . "\n";
 
 1;
Index: /trunk/ippScripts/scripts/ipp_serial_inject_mosaic.pl
===================================================================
--- /trunk/ippScripts/scripts/ipp_serial_inject_mosaic.pl	(revision 13274)
+++ /trunk/ippScripts/scripts/ipp_serial_inject_mosaic.pl	(revision 13275)
@@ -5,7 +5,6 @@
 
 use IPC::Cmd 0.36 qw( can_run run );
-use PS::IPP::Config;
+use PS::IPP::Config qw( caturi );
 use Data::Dumper;
-use File::Spec;
 
 use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt );
@@ -14,21 +13,26 @@
 my ($camera,			# Camera used
     $telescope,			# Telescope used
-    $workdir,			# Working directory to append
     $dbname,			# Database name
+    $workdir,			# Working directory
+    $path,			# Path to data
     );
 GetOptions(
-	   'camera|c=s' => \$camera,
+	   'camera|c=s'    => \$camera,
 	   'telescope|t=s' => \$telescope,
-	   'workdir=s' => \$workdir,
-	   'dbname=s' => \$dbname,
+	   'workdir=s'     => \$workdir,
+	   'path=s'        => \$path,
+	   'dbname=s'      => \$dbname,
 ) or pod2usage( 2 );
 
 pod2usage(
-	  -msg => "Required options: --camera --telescope --workdir --dbname",
+	  -msg => "Required options: --camera --telescope --workdir --path --dbname",
 	  -exitval => 3,
-	  ) unless defined $camera and defined $telescope and defined $workdir and defined $dbname;
+	  ) unless defined $camera
+    and defined $telescope
+    and defined $workdir
+    and defined $path
+    and defined $dbname;
 
 my $ipprc = PS::IPP::Config->new(); # IPP configuration
-my $workdir_abs = $ipprc->convert_filename_absolute( $workdir );
 
 # Look for programs we need
@@ -36,77 +40,84 @@
 my $pxinject = can_run('pxinject')  or (warn "Can't find pxinject" and $missing_tools = 1);
 
+if (scalar @ARGV == 0) {
+    die "No exposures provided.\n";
+}
+
 # Inject new data into the database
-if (scalar @ARGV != 0) {
-    my @classes;		# Names of the classes
-    my @files;			# What to add to the filename for each class
-    my $imfiles;
-    my $add_dir;		# Add directory name to get file name?
-    if ($camera eq "MEGACAM") {
-	for (my $i = 0; $i < 36; $i++) {
-	    push @classes, sprintf("ccd%02d", $i);
-	    push @files, sprintf(".ccd%02d", $i);
-	}
-    } elsif ($camera eq "MCSHORT") {
-	@classes = ( 'ccd12', 'ccd13', 'ccd14', 'ccd21', 'ccd22', 'ccd23' );
-	@files   = ( '.ccd12', '.ccd13', '.ccd14', '.ccd21', '.ccd22', '.ccd23' );
-	
-    } elsif ($camera eq "CTIO_MOSAIC2") {
-	@classes = ();
-	@files = ();
-    } elsif ($camera eq "TC3") {
-	@classes = ( 'CCID58-1-06b2', 'CCID45-1-14A', 'CCID45-1-11A', 'CCID45-1-22A',
-		   'CCID45-1-04C', 'CCID45-1-13A', 'CCID45-1-05A', 'CCID45-1-19A' );
-	@files = ( '00', '01', '10', '11', '20', '21', '30', '31' );
-	$add_dir = 1;
-    } elsif ($camera eq "SIMMOSAIC") {
-	@classes = ( 'Chip00', 'Chip01', 'Chip10', 'Chip11' );
-	@files   = ( '.Chip00', '.Chip01', '.Chip10', '.Chip11' );
-    } elsif ($camera eq "SIMTEST") {
-	@classes = ();
-	@files = ();
-    } else {
-	die "Unrecognised camera name: $camera.\n";
+my @classes;			# Names of the classes
+my @files;			# What to add to the filename for each class
+my $imfiles;
+my $add_dir;			# Add directory name to get file name?
+if ($camera eq "MEGACAM") {
+    for (my $i = 0; $i < 36; $i++) {
+	push @classes, sprintf("ccd%02d", $i);
+	push @files, sprintf(".ccd%02d", $i);
+    }
+} elsif ($camera eq "MCSHORT") {
+    @classes = ( 'ccd12', 'ccd13', 'ccd14', 'ccd21', 'ccd22', 'ccd23' );
+    @files   = ( '.ccd12', '.ccd13', '.ccd14', '.ccd21', '.ccd22', '.ccd23' );
+} elsif ($camera eq "CTIO_MOSAIC2") {
+    @classes = ();
+    @files = ();
+} elsif ($camera eq "TC3") {
+    @classes = ( 'CCID58-1-06b2', 'CCID45-1-14A', 'CCID45-1-11A', 'CCID45-1-22A',
+		 'CCID45-1-04C', 'CCID45-1-13A', 'CCID45-1-05A', 'CCID45-1-19A' );
+    @files = ( '00', '01', '10', '11', '20', '21', '30', '31' );
+    $add_dir = 1;
+} elsif ($camera eq "SIMMOSAIC") {
+    @classes = ( 'Chip00', 'Chip01', 'Chip10', 'Chip11' );
+    @files   = ( '.Chip00', '.Chip01', '.Chip10', '.Chip11' );
+} elsif ($camera eq "SIMTEST") {
+    @classes = ();
+    @files = ();
+} else {
+    die "Unrecognised camera name: $camera.\n";
+}
+
+foreach my $exp ( @ARGV ) {
+    my $command = "$pxinject -newExp -exp_id $exp -inst $camera -telescope $telescope -workdir $workdir -dbname $dbname -imfiles " . (scalar @classes or 1) ; # Command to run
+    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
+	run( command => $command, verbose => 1 );
+    die "Unable to inject $exp: $error_code\n" if not $success;
+    
+    my @line = split(/\s+/, $$stdout_buf[0]); # The output line, containing the exposure tag
+    my $exp_tag = $line[2];	# The exposure tag
+    for (my $i = 0; $i < scalar @classes; $i++) {
+	my $class_id = $classes[$i];
+	my $file_id = $files[$i];
+	my $filename = $exp . $file_id . '.fits';
+	$filename = caturi( $exp, $filename ) if defined $add_dir;
+	$filename = caturi( $path, $filename );
+
+	die "Unable to find file $filename" unless -f $ipprc->file_resolve( $filename );
+
+	$filename = $ipprc->convert_filename_relative( $filename );
+	my $command = "$pxinject -newImfile -exp_tag $exp_tag -class chip -class_id $class_id -uri $filename -dbname $dbname"; # Command to run
+	my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
+	    run( command => $command, verbose => 1 );
+	die "Unable to inject $exp $class_id: $error_code\n" if not $success;
     }
 
-    foreach my $exp ( @ARGV ) {
-	my $command = "$pxinject -newExp -exp_id $exp -inst $camera -telescope $telescope -workdir $workdir -dbname $dbname -imfiles " . (scalar @classes or 1) ; # Command to run
+    if (scalar @classes == 0) {
+	my $filename = "$exp.fits";
+	$filename = caturi( $exp, $filename ) if defined $add_dir;
+	$filename = caturi( $path, $filename );
+
+	die "Unable to find file $filename" unless -f $ipprc->file_resolve( $filename );
+
+	$filename = $ipprc->convert_filename_relative( $filename );
+	my $command = "$pxinject -newImfile -exp_tag $exp_tag -class fpa -class_id fpa -dbname $dbname -uri $filename"; # Command to run
 	my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
 	    run( command => $command, verbose => 1 );
-	die "Unable to inject $exp: $error_code\n" if not $success;
-	
-	my @line = split(/\s+/, $$stdout_buf[0]); # The output line, containing the exposure tag
-	my $exp_tag = $line[2];	# The exposure tag
-	for (my $i = 0; $i < scalar @classes; $i++) {
-	    my $class_id = $classes[$i];
-	    my $file_id = $files[$i];
-	    my $filename = "$exp$file_id.fits";
-	    $filename = File::Spec->catfile( $exp, $filename ) if defined $add_dir;
-	    $filename = File::Spec->catfile( $workdir_abs, $filename);
-	    $filename = $ipprc->convert_filename_relative( $filename );
-	    my $command = "$pxinject -newImfile -exp_tag $exp_tag -class chip -class_id $class_id -uri $filename -dbname $dbname"; # Command to run
-	    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
-		run( command => $command, verbose => 1 );
-	    die "Unable to inject $exp $class_id: $error_code\n" if not $success;
-	}
+	die "Unable to inject $exp imfile: $error_code\n" if not $success;
+    }
 
-	if (scalar @classes == 0) {
-	    my $filename = "$exp.fits";
-	    $filename = File::Spec->catfile( $exp, $filename ) if defined $add_dir;
-	    $filename = File::Spec->catfile( $workdir_abs, $filename);
-	    $filename = $ipprc->convert_filename_relative( $filename );
-	    my $command = "$pxinject -newImfile -exp_tag $exp_tag -class fpa -class_id fpa -dbname $dbname -uri $filename"; # Command to run
-	    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
-		run( command => $command, verbose => 1 );
-	    die "Unable to inject $exp imfile: $error_code\n" if not $success;
-	}
-
-    }
 }
 
 END {
     my $status = $?;
-    system("sync") == 0
-        or die "failed to execute sync: $!" ;
-    $? = $status;
+system("sync") == 0
+    or die "failed to execute sync: $!" ;
+$? = $status;
 }
 
Index: /trunk/ippScripts/scripts/ipp_simulation_data.pl
===================================================================
--- /trunk/ippScripts/scripts/ipp_simulation_data.pl	(revision 13274)
+++ /trunk/ippScripts/scripts/ipp_simulation_data.pl	(revision 13275)
@@ -13,12 +13,13 @@
 use Pod::Usage qw( pod2usage );
 use PS::IPP::Config qw(
-    $PS_EXIT_SUCCESS
-    $PS_EXIT_UNKNOWN_ERROR
-    $PS_EXIT_SYS_ERROR
-    $PS_EXIT_CONFIG_ERROR
-    $PS_EXIT_PROG_ERROR
-    $PS_EXIT_DATA_ERROR
-    $PS_EXIT_TIMEOUT_ERROR
-    );
+		       $PS_EXIT_SUCCESS
+		       $PS_EXIT_UNKNOWN_ERROR
+		       $PS_EXIT_SYS_ERROR
+		       $PS_EXIT_CONFIG_ERROR
+		       $PS_EXIT_PROG_ERROR
+		       $PS_EXIT_DATA_ERROR
+		       $PS_EXIT_TIMEOUT_ERROR
+		       caturi
+		       );
 
 my $ipprc = PS::IPP::Config->new(); # IPP configuration
@@ -28,4 +29,5 @@
     $telescope,			# Telesceope name
     $dbname,			# Database name
+    $path,			# Path to data
     $workdir,			# Working directory for data
     $no_update			# Don't update the database
@@ -37,4 +39,5 @@
 	   'telescope=s'   => \$telescope,
 	   'dbname=s'      => \$dbname,
+	   'path=s'        => \$path,
 	   'workdir=s'     => \$workdir,
 	   'no-update'     => \$no_update,
@@ -44,12 +47,14 @@
 
 pod2usage(
-          -msg => "Required options: --name --camera --telescope --dbname",
+          -msg => "Required options: --name --path --camera --telescope --dbname",
 	    -exitval => 3,
 	  ) unless
     defined $name and
+    defined $path and
     defined $camera and
     defined $telescope and
     defined $dbname;
 
+$workdir = $path if not defined $workdir;
 
 # Look for programs we need
@@ -64,6 +69,4 @@
     exit($PS_EXIT_CONFIG_ERROR); 
 }
-
-$workdir = $ipprc->convert_filename_absolute( $workdir );
 
 # Number of bias images
@@ -120,8 +123,8 @@
     my $basename;		# Output base filename
     ( $basename, $counter ) = filename( $name, $counter );
-    my $filename = File::Spec->catfile( $workdir, $basename ) if defined $workdir; # File name
+    my $filename = caturi( $path, $basename );
     run( command => "$ppSim -camera $camera -type BIAS $filename",
 	 verbose => 1 ) or die "Unable to run ppSim";
-    run( command => "$inject --camera $camera --telescope $telescope --workdir $workdir " .
+    run( command => "$inject --camera $camera --telescope $telescope --path $path --workdir $workdir " .
 	 "--dbname $dbname $basename",
 	 verbose => 1 ) or die "Unable to inject file.";
@@ -132,8 +135,8 @@
     my $basename;		# Output base filename
     ( $basename, $counter ) = filename( $name, $counter );
-    my $filename = File::Spec->catfile( $workdir, $basename ) if defined $workdir; # File name
+    my $filename = caturi( $path, $basename );
     run ( command => "$ppSim -camera $camera -type DARK -exptime $exptime $filename",
 	  verbose => 1 ) or die "Unable to run ppSim";
-    run( command => "$inject --camera $camera --telescope $telescope --workdir $workdir " .
+    run( command => "$inject --camera $camera --telescope $telescope --path $path --workdir $workdir " .
 	 "--dbname $dbname $basename",
 	 verbose => 1 ) or die "Unable to inject file.";
@@ -146,8 +149,8 @@
 	my $basename;		# Output base filename
 	( $basename, $counter ) = filename( $name, $counter );
-	my $filename = File::Spec->catfile( $workdir, $basename ) if defined $workdir; # File name
+	my $filename = caturi( $path, $basename );
 	run( command => "$ppSim -camera $camera -type FLAT -filter $filter -exptime $exptime $filename",
 	     verbose => 1 ) or die "Unable to run ppSim";
-        run( command => "$inject --camera $camera --telescope $telescope --workdir $workdir " .
+        run( command => "$inject --camera $camera --telescope $telescope --path $path --workdir $workdir " .
 	     "--dbname $dbname $basename",
 	     verbose => 1 ) or die "Unable to inject file.";
@@ -174,10 +177,10 @@
 	my $basename;		# Output base filename
 	( $basename, $counter ) = filename( $name, $counter );
-	my $filename = File::Spec->catfile( $workdir, $basename ) if defined $workdir; # File name
+	my $filename = caturi( $path, $basename );
 	run( command => "$ppSim -camera $camera -type OBJECT -filter $filter -exptime $exptime " .
 	     "-skyrate $sky -ra $ra -dec $dec -pa $pa -scale $scale -zp $zp -seeing $seeing $filename",
 	     verbose => 1 ) or die "Unable to run ppSim";
-	run( command => "$inject --camera $camera --telescope $telescope --workdir $workdir " .
-	     "--dbname $dbname $basename ",
+	run( command => "$inject --camera $camera --telescope $telescope --path $path --workdir $workdir " .
+	     "--dbname $dbname $basename",
 	     verbose => 1 ) or die "Unable to inject file.";
     }
@@ -199,6 +202,3 @@
 }
 
-
-
-
 __END__
Index: /trunk/ippScripts/scripts/register_imfile.pl
===================================================================
--- /trunk/ippScripts/scripts/register_imfile.pl	(revision 13274)
+++ /trunk/ippScripts/scripts/register_imfile.pl	(revision 13275)
@@ -59,5 +59,4 @@
 
 my $RECIPE = "PPSTATS_PHASE0"; # Recipe to use for ppStats
-# use constant RECIPE => "PPSTATS_PHASE0"; # Recipe to use for ppStats
 
 # These values should be constant for all components
@@ -104,7 +103,4 @@
 );
 
-# Resolve the input URI
-$uri = $ipprc->convert_filename_absolute($uri);
-
 # Run ppStats on the input file
 my $stats;
@@ -131,16 +127,15 @@
     unless ($stats->parse($metadata)) {
         warn ("Unable to find all values");
-        &my_die ($exp_tag, $class_id, $PS_EXIT_PROG_ERROR);
-        # XXX is this a programming or a config error?
+        &my_die ($exp_tag, $class_id, $PS_EXIT_CONFIG_ERROR);
     }
 
     if (0) {
-    # XXX for a test, randomly declare a failure and return to pantasks
-    my $rnd = rand(1);
-    if ($rnd > 0.5) {
-        warn ("random failure");
-        &my_die ($exp_tag, $class_id, $PS_EXIT_DATA_ERROR);
-    }
-}
+	# XXX for a test, randomly declare a failure and return to pantasks
+	my $rnd = rand(1);
+	if ($rnd > 0.5) {
+	    warn ("random failure");
+	    &my_die ($exp_tag, $class_id, $PS_EXIT_DATA_ERROR);
+	}
+    }
 }
 
@@ -175,8 +170,6 @@
     unless ($success) {
 	$error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
-        # XXX if we can't run -addprocessedimfile, we can't actually set the
-        # error code.
-        # XXX if this is not a database error, it is probably a
-        # programming error (in regtool or the passed args)
+        # If we can't run -addprocessedimfile, we can't actually set the error code. If this is not
+	# a database error, it is probably a programming error (in regtool or the passed args)
         warn ("Unable to perform regtool -addprocessedimfile: $error_code");
         exit($error_code);
Index: /trunk/ippScripts/scripts/stack_skycell.pl
===================================================================
--- /trunk/ippScripts/scripts/stack_skycell.pl	(revision 13274)
+++ /trunk/ippScripts/scripts/stack_skycell.pl	(revision 13275)
@@ -19,15 +19,14 @@
 use Data::Dumper;
 
-use PS::IPP::Config qw(
-    $PS_EXIT_SUCCESS
-    $PS_EXIT_UNKNOWN_ERROR
-    $PS_EXIT_SYS_ERROR
-    $PS_EXIT_CONFIG_ERROR
-    $PS_EXIT_PROG_ERROR
-    $PS_EXIT_DATA_ERROR
-    $PS_EXIT_TIMEOUT_ERROR
-    );
+use PS::IPP::Config qw($PS_EXIT_SUCCESS
+		       $PS_EXIT_UNKNOWN_ERROR
+		       $PS_EXIT_SYS_ERROR
+		       $PS_EXIT_CONFIG_ERROR
+		       $PS_EXIT_PROG_ERROR
+		       $PS_EXIT_DATA_ERROR
+		       $PS_EXIT_TIMEOUT_ERROR
+		       caturi
+		       );
 my $ipprc = PS::IPP::Config->new(); # IPP configuration
-use File::Spec;
 
 use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt );
@@ -86,6 +85,5 @@
 my $camera;			# Camera
 foreach my $file (@$files) {
-    my $uri = $ipprc->convert_filename_absolute( $file->{uri} ); # URI for file
-    $inputList .= "$uri ";
+    $inputList .= $file->{uri} . ' ';
     if (defined $tess_id) {
 	&my_die("Tesselation identifiers don't match", $stack_id, $PS_EXIT_SYS_ERROR) unless
@@ -110,19 +108,7 @@
 $ipprc->define_camera($camera);
 
-
-### Working directory
-if (defined $workdir) {
-    $workdir = $ipprc->convert_filename_absolute( $workdir );
-    $workdir = File::Spec->catdir( $workdir, "tess_" . $tess_id, "sky_" . $skycell_id );
-} else {
-    my ($vol, $dir, $file) = File::Spec->splitpath( $ipprc->convert_filename_absolute( $$files[0]->{uri} ) );
-    $workdir = $dir;
-}
-system "mkdir -p $workdir" unless -d $workdir;
-
 # Get the output filenames
-my $outputFile = "$tess_id.$skycell_id.stk$stack_id"; # Root name
-my $outputRoot = File::Spec->catfile( $workdir, $outputFile );
-
+$workdir = caturi( $workdir, "tess_" . $tess_id, "sky_" . $skycell_id ) if defined $workdir;
+my $outputRoot = $ipprc->file_prepare( "$tess_id.$skycell_id.stk$stack_id", $workdir, $$files[0]->{uri} );
 my $outputName = $outputRoot . ".fits";
 #my $bin1Name =  $ipprc->filename("PPSTAC.BIN1", $outputRoot);
@@ -141,13 +127,13 @@
 	&my_die("Unable to perform ppImage: $error_code", $stack_id, $error_code);
     }
-    &my_die("Couldn't find expected output file: $outputName", $stack_id, $PS_EXIT_SYS_ERROR) unless -f $outputName;
-#    &my_die("Couldn't find expected output file: $bin1Name",    $stack_id, $PS_EXIT_SYS_ERROR) unless -f $bin1Name;
-#    &my_die("Couldn't find expected output file: $bin2Name",    $stack_id, $PS_EXIT_SYS_ERROR) unless -f $bin2Name;
-#    &my_die("Couldn't find expected output file: $outputStats", $stack_id, $PS_EXIT_SYS_ERROR) unless -f $outputStats;
+    &my_die("Couldn't find expected output file: $outputName", $stack_id, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($outputName);
+#    &my_die("Couldn't find expected output file: $bin1Name",    $stack_id, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($bin1Name);
+#    &my_die("Couldn't find expected output file: $bin2Name",    $stack_id, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($bin2Name);
+#    &my_die("Couldn't find expected output file: $outputStats", $stack_id, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($outputStats);
 
     # Get the statistics on the residual image
     if (0) { ### Disabled because ppStac doesn't output stats yet
 	my $statsFile;		# File handle
-	open $statsFile, $outputStats or &my_die("Can't open statistics file $outputStats: $!", $stack_id, $PS_EXIT_SYS_ERROR);
+	open $statsFile, $ipprc->file_resolve($outputStats) or &my_die("Can't open statistics file $outputStats: $!", $stack_id, $PS_EXIT_SYS_ERROR);
 	my @contents = <$statsFile>; # Contents of file
 	close $statsFile;
@@ -159,7 +145,4 @@
 
 # Add the processed file to the database
-$outputName = $ipprc->convert_filename_relative( $outputName );
-$outputRoot = $ipprc->convert_filename_relative( $outputRoot );
-
 my $bg = ($stats->bg_mean() or 'NAN');
 my $bg_stdev = ($stats->bg_stdev() or 'NAN');
@@ -179,6 +162,4 @@
 	    &my_die("Unable to perform stacktool -addsumskyfile: $error_code", $stack_id, $error_code);
 	}
-	
-#	unlink $outputStats;    
     }
 
Index: /trunk/ippScripts/scripts/warp_overlap.pl
===================================================================
--- /trunk/ippScripts/scripts/warp_overlap.pl	(revision 13274)
+++ /trunk/ippScripts/scripts/warp_overlap.pl	(revision 13275)
@@ -17,15 +17,16 @@
 use PS::IPP::Metadata::Stats;
 use PS::IPP::Metadata::List qw( parse_md_list );
-
-use PS::IPP::Config qw(
-    $PS_EXIT_SUCCESS
-    $PS_EXIT_UNKNOWN_ERROR
-    $PS_EXIT_SYS_ERROR
-    $PS_EXIT_CONFIG_ERROR
-    $PS_EXIT_PROG_ERROR
-    $PS_EXIT_DATA_ERROR
-    $PS_EXIT_TIMEOUT_ERROR
-    metadataLookupStr
-    );
+use File::Temp qw( tempfile );
+
+use PS::IPP::Config qw($PS_EXIT_SUCCESS
+		       $PS_EXIT_UNKNOWN_ERROR
+		       $PS_EXIT_SYS_ERROR
+		       $PS_EXIT_CONFIG_ERROR
+		       $PS_EXIT_PROG_ERROR
+		       $PS_EXIT_DATA_ERROR
+		       $PS_EXIT_TIMEOUT_ERROR
+		       metadataLookupStr
+		       caturi
+		       );
 my $ipprc = PS::IPP::Config->new(); # IPP configuration
 use File::Spec;
@@ -82,25 +83,4 @@
 }
 
-# Make sure everything is from the same exposure, and get the exposure tag
-my $exp_tag;			# Exposure tag
-foreach my $imfile ( @$imfiles ) {
-    unless (defined $exp_tag) {
-	$exp_tag = $imfile->{exp_tag};
-    } elsif ($exp_tag ne $imfile->{exp_tag}) {
-	&my_die("Multiple exposures in the same warp.", $warp_id, $PS_EXIT_SYS_ERROR);
-    }
-}
-
-# Set output directory
-if (defined $workdir) {
-    $workdir = $ipprc->convert_filename_absolute( $workdir );
-} else {
-    my $example = $ipprc->convert_filename_absolute( $$imfiles[0]->{uri} );
-    my ($vol, $dir, $file) = File::Spec->splitpath( $example );
-    $workdir = $dir;
-}
-system "mkdir -p $workdir" unless -d $workdir;
-
-
 # Determine the imfile/skycell overlaps
 my @overlaps = ();
@@ -111,9 +91,15 @@
     my $tessellations = $ipprc->tessellations(); # Hash of defined tessellations
     foreach my $tess_id ( keys %$tessellations ) {
+	### Because DVO doesn't use psModules, it doesn't understand Nebulous --- check
+	my $uri = URI->new( $$tessellations{$tess_id} );
+	if (defined $uri->scheme() and $uri->scheme() eq 'neb') {
+	    &my_die("Tessellation $tess_id refers to a Nebulous path: $$tessellations{$tess_id}", $warp_id, $PS_EXIT_CONFIG_ERROR);
+	}		    
+	
 	my $tess_dir = $ipprc->convert_filename_absolute( $$tessellations{$tess_id} ); # Catdir for DVO
 	print STDERR "tessellation: $tess_id, $tess_dir\n";
 
 	my $imfile = $imfiles->[0];
-	my $camRoot = $ipprc->convert_filename_absolute( $imfile->{cam_path_base} );
+	my $camRoot = $imfile->{cam_path_base};
 	my $psastroFile = $ipprc->filename("PSASTRO.OUTPUT", $camRoot); # MEF psastro output
 	
@@ -123,5 +109,5 @@
 	
 	# run the dvoImageOverlaps program to get the overlaps with this image 
-	my $command = "$dvoImageOverlaps -D CATDIR $tess_dir $psastroFile";
+	my $command = "$dvoImageOverlaps -D CATDIR $tess_dir " . $ipprc->file_resolve($psastroFile);
 	my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
 	    run(command => $command, verbose => 1);
@@ -145,5 +131,5 @@
 	    if ($fileLevel eq "chip") {
 		my $class_id = $imfile->{class_id};
-		my $chipRoot = $ipprc->convert_filename_absolute( $imfile->{chip_path_base} );
+		my $chipRoot = $ipprc->file_resolve( $imfile->{chip_path_base} );
 		my $extname = $ipprc->extname_rule("CMF.HEAD", $class_id); # MEF psastro output
 		
@@ -176,13 +162,15 @@
 	# Extract the skycells to images, used as warp templates.
 	foreach my $skycell_id (@unique_skycells) {
-	    my $skyDir = File::Spec->catdir($workdir, "tess_" . $tess_id, "sky_" . $skycell_id );
-	    system "mkdir -p $skyDir" unless -d $skyDir;
-	    my $skyFile = File::Spec->catfile( $skyDir , $skycell_id );
-	    my $command = "$dvoImageExtract -D CATDIR $tess_dir $skycell_id -o $skyFile";
-	    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
-		run(command => $command, verbose => 1);
-	    unless ($success) {
-		$error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
-		&my_die("Unable to perform dvoImageExtract: $error_code", $warp_id, $error_code);
+	    my $skyDir = caturi($workdir, "tess_" . $tess_id, "sky_" . $skycell_id );
+	    my $skyFile = $ipprc->file_prepare( $skycell_id, $skyDir );
+	    unless ($ipprc->file_exists( $skyFile )) {
+		my $skyFileResolved = $ipprc->file_create( $skyFile ); # Resolved filename, for Nebulous
+		my $command = "$dvoImageExtract -D CATDIR $tess_dir $skycell_id -o $skyFileResolved";
+		my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
+		    run(command => $command, verbose => 1);
+		unless ($success) {
+		    $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
+		    &my_die("Unable to perform dvoImageExtract: $error_code", $warp_id, $error_code);
+		}
 	    }
 	}
@@ -202,6 +190,5 @@
 
 # Generate a MDC file with the overlaps
-my $overlapName = File::Spec->catfile( $workdir, 'overlaps.wrp' . $warp_id . '.mdc' );
-open my $overlapFile, "> $overlapName" or die "Unable to open mdc file $overlapName";
+my ($overlapFile, $overlapName) = tempfile( 'overlaps.wrp' . $warp_id . '.mdc.XXXX', UNLINK => 1 );
 print $overlapFile "warpSkyCellMap MULTI\n\n";
 foreach my $overlap (@overlaps) {
@@ -229,6 +216,4 @@
 	exit($error_code);
     }
-
-    unlink $overlapName;
 }
 
Index: /trunk/ippScripts/scripts/warp_skycell.pl
===================================================================
--- /trunk/ippScripts/scripts/warp_skycell.pl	(revision 13274)
+++ /trunk/ippScripts/scripts/warp_skycell.pl	(revision 13275)
@@ -18,15 +18,16 @@
 use PS::IPP::Metadata::List qw( parse_md_list );
 
-use PS::IPP::Config qw(
-    $PS_EXIT_SUCCESS
-    $PS_EXIT_UNKNOWN_ERROR
-    $PS_EXIT_SYS_ERROR
-    $PS_EXIT_CONFIG_ERROR
-    $PS_EXIT_PROG_ERROR
-    $PS_EXIT_DATA_ERROR
-    $PS_EXIT_TIMEOUT_ERROR
-    );
+use PS::IPP::Config qw($PS_EXIT_SUCCESS
+		       $PS_EXIT_UNKNOWN_ERROR
+		       $PS_EXIT_SYS_ERROR
+		       $PS_EXIT_CONFIG_ERROR
+		       $PS_EXIT_PROG_ERROR
+		       $PS_EXIT_DATA_ERROR
+		       $PS_EXIT_TIMEOUT_ERROR
+		       caturi
+		       );
 my $ipprc = PS::IPP::Config->new(); # IPP configuration
 use File::Spec;
+use File::Temp qw( tempfile );
 
 use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt );
@@ -84,30 +85,16 @@
 }
 
-# Set output directory
-if (defined $workdir) {
-    $workdir = $ipprc->convert_filename_absolute( $workdir );
-    $workdir = File::Spec->catdir( $workdir, "tess_" . $tess_id, "sky_" . $skycell_id );
-} else {
-    my $example = $ipprc->convert_filename_absolute( $$imfiles[0]->{uri} );
-    my ($vol, $dir, $file) = File::Spec->splitpath( $example );
-    $workdir = $dir;
-}
-system "mkdir -p $workdir" unless -d $workdir;
-
-my $outputFile = "$tess_id.$skycell_id.wrp$warp_id"; # Root name
-my $outputRoot = File::Spec->catfile( $workdir, $outputFile );
+$workdir = caturi( $workdir, "tess_" . $tess_id, "sky_" . $skycell_id ) if defined $workdir;
+my $outputRoot = $ipprc->file_prepare( "$tess_id.$skycell_id.wrp$warp_id", $workdir, $$imfiles[0]->{uri} );
 my $outputImage = $ipprc->filename("PSWARP.OUTPUT", $outputRoot, $skycell_id );
 my $outputBin1 = $ipprc->filename("PSWARP.BIN1", $outputRoot, $skycell_id );
 my $outputBin2 = $ipprc->filename("PSWARP.BIN2", $outputRoot, $skycell_id );
 my $outputStats = $outputRoot . '.stats';
-my $skyFile = File::Spec->catfile( $workdir, $skycell_id ); # Target sky cell file
-my $listName = $outputRoot . '.list';
+my $skyFile = caturi( $workdir, $skycell_id ); # Target sky cell file
 
 # Get list of filenames
-open my $listFile, "> $listName" or &my_die("Unable to open $listName", $warp_id, $skycell_id, $tess_id, $PS_EXIT_SYS_ERROR);
+my ($listFile, $listName) = tempfile( "$tess_id.$skycell_id.wrp$warp_id.list.XXXX", UNLINK => 1);
 foreach my $imfile (@$imfiles) {
-    my $uri = $ipprc->convert_filename_absolute( $imfile->{uri} );
-
-    print $listFile "$uri\n";
+    print $listFile ( $imfile->{uri} . "\n");
 }
 close $listFile;
@@ -123,12 +110,12 @@
 	&my_die("Unable to perform pswarp: $error_code", $warp_id, $skycell_id, $error_code);
     }
-    &my_die("Couldn't find expected output file: $outputImage", $warp_id, $skycell_id, $tess_id, $PS_EXIT_SYS_ERROR) unless -f $outputImage;
-    &my_die("Couldn't find expected output file: $outputStats", $warp_id, $skycell_id, $tess_id, $PS_EXIT_SYS_ERROR) unless -f $outputStats;
-#    &my_die("Couldn't find expected output file: $outputBin1", $warp_id, $skycell_id, $tess_id, $PS_EXIT_SYS_ERROR) unless -f $outputBin1;
-#    &my_die("Couldn't find expected output file: $outputBin2", $warp_id, $skycell_id, $tess_id, $PS_EXIT_SYS_ERROR) unless -f $outputBin2;
+    &my_die("Couldn't find expected output file: $outputImage", $warp_id, $skycell_id, $tess_id, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($outputImage);
+    &my_die("Couldn't find expected output file: $outputStats", $warp_id, $skycell_id, $tess_id, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($outputStats);
+#    &my_die("Couldn't find expected output file: $outputBin1", $warp_id, $skycell_id, $tess_id, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($outputBin1);
+#    &my_die("Couldn't find expected output file: $outputBin2", $warp_id, $skycell_id, $tess_id, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($outputBin2);
 
     # Get the statistics on the warped image
     my $statsFile;		# File handle
-    open $statsFile, "$outputStats" or die "Can't open statistics file $outputStats: $!\n";
+    open $statsFile, $ipprc->file_resolve($outputStats) or die "Can't open statistics file $outputStats: $!\n";
     my @contents = <$statsFile>; # Contents of file
     close $statsFile;
@@ -138,12 +125,7 @@
 }
 
-# Take off the absolute path, to stuff into the database
-$outputImage = $ipprc->convert_filename_relative( $outputImage );
-$outputRoot = $ipprc->convert_filename_relative( $outputRoot );
-
+# Add the processed file to the database
 my $bg = ($stats->bg_mean() or 'NAN');
 my $bg_stdev = ($stats->bg_stdev() or 'NAN');
-
-# Add the processed file to the database
 unless ($no_update) {
     my $command = "$warptool -addwarped -warp_id $warp_id -skycell_id $skycell_id -tess_id $tess_id" .
@@ -159,6 +141,4 @@
 	exit($error_code);
     }
-
-    unlink $outputStats;
 }
 
