Index: trunk/ippScripts/scripts/receive_file.pl
===================================================================
--- trunk/ippScripts/scripts/receive_file.pl	(revision 23892)
+++ trunk/ippScripts/scripts/receive_file.pl	(revision 23894)
@@ -65,5 +65,5 @@
 my $filename = "$tempdir/$file";  # Target filename
 {
-    my $uri = "$source/product/$fileset/$file"; # URI for datastore file
+    my $uri = "$source/$product/$fileset/$file"; # URI for datastore file
     my $command = "dsget --uri $uri --filename $filename"; # Command to execute
 
@@ -81,4 +81,5 @@
 
     my $command = "$tool -importrun -infile $filename"; # Command to execute
+    $command .= " -dbname $dbname" if defined $dbname;
     my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
         run(command => $command, verbose => $verbose);
@@ -88,10 +89,11 @@
     my @files = ();
     {
-        my $command = "tar -C $tempdir -tvzf $filename"; # Command to execute
+        my $command = "tar -C $tempdir -tzf $filename"; # Command to execute
         my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
             run(command => $command, verbose => $verbose);
         die "Unable to get listing of tar file $filename\n" unless $success;
 
-        foreach my $line (@$stdout_buf) {
+        my @lines = split(/\n/, join "", @$stdout_buf); # Lines from output
+        foreach my $line ( @lines ) {
             $line =~ s/\#.*$//;
             next unless $line =~ /\S+/;
@@ -99,5 +101,5 @@
             my $file = $fields[0];      # Name of file
             $file =~ s|^./||;
-            push @files, $file if defined $file;
+            push @files, $file if $file =~ /\S+/;
         }
     }
@@ -115,5 +117,5 @@
         my $from = "$tempdir/$file"; # Source for file
         my $target = "$workdir/$file"; # Target destination for file
-        my $to = $ipprc->file_prepare( $target ); # Target for move
+        my $to = $ipprc->file_create( $target ); # Target for move
         system("mv $from $to") == 0 or die "Unable to move $file into workdir $workdir: $!\n";
     }
@@ -129,8 +131,11 @@
 {
     my $command = "$receivetool -addresult";
-    $command .= " -file $file_id";
+    $command .= " -file_id $file_id";
     $command .= (" -dtime_copy " . (($mjd_copy - $mjd_start) * 86400));
-    $command .= (" -dtime_extract " . (($mjd_extract - $mjd_start) * 86400));
+    $command .= (" -dtime_extract " . (($mjd_extract - $mjd_copy) * 86400));
     $command .= " -dbname $dbname" if defined $dbname;
+
+
+    print "$command\n";
 
     unless (defined $no_update) {
Index: trunk/ippScripts/scripts/receive_fileset.pl
===================================================================
--- trunk/ippScripts/scripts/receive_fileset.pl	(revision 23892)
+++ trunk/ippScripts/scripts/receive_fileset.pl	(revision 23894)
@@ -55,5 +55,5 @@
 my @files = ();                 # Files to add
 {
-    my $uri = "$source/product/$fileset"; # URI for datastore fileset
+    my $uri = "$source/$product/$fileset"; # URI for datastore fileset
     $uri .= "/index.txt" unless $uri =~ m|/index.txt$|;
     my $command = "dsfilesetls --uri $uri"; # Command to execute
@@ -64,5 +64,6 @@
 
     # Get files
-    foreach my $line (@$stdout_buf) {
+    my @lines = split(/\n/, join "", @$stdout_buf); # Lines from output
+    foreach my $line ( @lines ) {
         $line =~ s/\#.*$//;
         next unless $line =~ /\S+/;
@@ -77,5 +78,5 @@
     my $command = "receivetool -addfile"; # Command to execute
     $command .= " -fileset_id $fileset_id";
-    $command .= " -file" . join(' -file', @files);
+    $command .= " -file " . join(' -file ', @files);
     $command .= " -dbname $dbname" if defined $dbname;
 
Index: trunk/ippScripts/scripts/receive_source.pl
===================================================================
--- trunk/ippScripts/scripts/receive_source.pl	(revision 23892)
+++ trunk/ippScripts/scripts/receive_source.pl	(revision 23894)
@@ -55,5 +55,5 @@
 $uri .= "/index.txt" unless $uri =~ m|/index.txt$|;
 my $command = "dsproductls --uri $uri"; # Command to execute
-$command .= "--last_fileset $last_fileset" if defined $last_fileset;
+$command .= " --last_fileset $last_fileset" if defined $last_fileset;
 
 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
@@ -61,7 +61,8 @@
 die "Unable to get source listing from $source for $product\n" unless $success;
 
-# Add filesets
-my $last;                   # Last fileset seen
-foreach my $line (@$stdout_buf) {
+# Parse list of filesets
+my @filesets = ();              # Filesets to add
+my @lines = split(/\n/, join "", @$stdout_buf); # Lines from output
+foreach my $line ( @lines ) {
     $line =~ s/\#.*//g;
     next unless $line =~ /\S+/;
@@ -69,30 +70,35 @@
     my @fields = split(/\s+/, $line); # Fields in line
     my $fileset = $fields[1];
-    next if not defined $fileset;
-
-    my $command = "receivetool -addfileset"; # Command to execute
-    $command .= " -source_id $source_id";
-    $command .= " -fileset $fileset";
-    $command .= " -dbname $dbname" if defined $dbname;
-
-    unless (defined $no_update) {
-        my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
-            run(command => $command, verbose => $verbose);
-        die "Unable to add fileset $fileset\n" unless $success;
-        $last = $fileset;
-    }
+    push @filesets, $fileset if defined $fileset and $fileset =~ /\S+/;
 }
 
-# Update the last fileset seen
-if (defined $last and (not defined $last_fileset or $last ne $last_fileset)) {
-    my $command = "receivetool -updatelast"; # Command to execute
-    $command .= " -source_id $source_id";
-    $command .= " -fileset $last";
-    $command .= " -dbname $dbname" if defined $dbname;
+if (scalar @filesets > 0) {
+    # Add filesets
+    {
+        my $command = "receivetool -addfileset"; # Command to execute
+        $command .= " -src_id $source_id";
+        $command .= " -fileset " . join(' -fileset ', @filesets);
+        $command .= " -dbname $dbname" if defined $dbname;
 
-    unless (defined $no_update) {
-        my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
-            run(command => $command, verbose => $verbose);
-        die "Unable to update last fileset to $last\n" unless $success;
+        unless (defined $no_update) {
+            my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
+                run(command => $command, verbose => $verbose);
+            die "Unable to add filesets from $source for $product\n" unless $success;
+        }
+    }
+
+    # Update the last fileset seen
+    {
+        my $command = "receivetool -updatelast"; # Command to execute
+        $command .= " -src_id $source_id";
+        my $last = pop @filesets; # Last fileset
+        $command .= " -fileset $last";
+        $command .= " -dbname $dbname" if defined $dbname;
+
+        unless (defined $no_update) {
+            my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
+                run(command => $command, verbose => $verbose);
+            die "Unable to update last fileset to $last\n" unless $success;
+        }
     }
 }
