Index: trunk/ippScripts/scripts/receive_file.pl
===================================================================
--- trunk/ippScripts/scripts/receive_file.pl	(revision 24872)
+++ trunk/ippScripts/scripts/receive_file.pl	(revision 24894)
@@ -19,5 +19,5 @@
 use PS::IPP::Metadata::List qw( parse_md_list );
 use PS::IPP::Config 1.01 qw( :standard );
-use File::Temp qw( tempfile );
+use File::Temp qw( tempfile tempdir );
 use File::Basename qw( basename );
 use Carp;
@@ -35,5 +35,5 @@
 }
 
-my $tempdir = "/tmp";
+my $temproot = "/tmp";
 
 # Parse the command-line arguments
@@ -72,5 +72,5 @@
     defined $workdir;
 
-$tempdir .= "/$file_id";
+my $tempdir = tempdir( "$temproot/receive.$file_id.XXXX", CLEANUP => !$save_temps);
 
 &my_die( "dirinfo is NULL for $component", $file_id, $PS_EXIT_CONFIG_ERROR )
@@ -329,9 +329,5 @@
 }
 
-if (!$save_temps and -e $filename) {
-    unlink $filename or &my_die( "Unable to unlink $filename\n", $file_id, $PS_EXIT_UNKNOWN_ERROR);
-}
 my $mjd_extract = DateTime->now->mjd;   # MJD of finishing extract
-
 
 # All done
