Changeset 23895
- Timestamp:
- Apr 17, 2009, 9:02:27 AM (17 years ago)
- File:
-
- 1 edited
-
trunk/ippScripts/scripts/receive_file.pl (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippScripts/scripts/receive_file.pl
r23894 r23895 18 18 use PS::IPP::Metadata::Config; 19 19 use PS::IPP::Config 1.01 qw( :standard ); 20 use File::Temp qw( tempfile ); 20 21 use Carp; 21 22 … … 35 36 36 37 # Parse the command-line arguments 37 my ( $file_id, $source, $product, $fileset, $file, $workdir, $dbname, $verbose, $no_update );38 my ( $file_id, $source, $product, $fileset, $file, $workdir, $dbname, $verbose, $no_update, $save_temps ); 38 39 39 40 GetOptions( … … 47 48 'verbose' => \$verbose, # Print to stdout 48 49 'no-update' => \$no_update, # Don't update the database? 50 'save-temps' => \$save_temps, # Save temporary files? 49 51 ) or pod2usage( 2 ); 50 52 … … 77 79 if ($file =~ m|^dbinfo\.\S+\.mdc$|) { 78 80 # Load into database 81 82 # Need to fix paths to point to new workdir 83 my ($fixFile, $fixName) = tempfile( "$tempdir/$file.XXXX", UNLINK => !$save_temps ); # Fixed file 84 open my $inFile, $filename or die "Can't open $filename\n"; # Input file 85 my $workdir_old; # Old workdir 86 while (<$inFile>) { 87 # XXX This is a global approach to fixing the path: it should fix anything and everything, but won't 88 # work if there are multiple workdirs in a file and the bits are all mixed up. To cover that case, 89 # we should fix each of the elements (workdir, uri, path_base) separately. 90 if (m|^\s*workdir\s+STR\s+(\S+)|) { 91 $workdir_old = $1; 92 $workdir_old =~ s|\@HOST\@|\\S+|; 93 } 94 if (defined $workdir_old) { 95 s|$workdir_old|$workdir|; 96 } 97 print $fixFile $_; 98 } 99 close($inFile); 100 79 101 my ($stage) = $file =~ m|^dbinfo\.(\S+)\.\d+\.mdc$|; # Stage of interest 80 102 my $tool = can_run("${stage}tool") or die "Can't find tool to load $file\n"; 81 103 82 my $command = "$tool -importrun -infile $fi lename"; # Command to execute104 my $command = "$tool -importrun -infile $fixName"; # Command to execute 83 105 $command .= " -dbname $dbname" if defined $dbname; 84 106 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 85 107 run(command => $command, verbose => $verbose); 86 die "Unable to load $fi lename\n" unless $success;108 die "Unable to load $fixName\n" unless $success; 87 109 } elsif ($file =~ m|.*\.tgz$|) { 88 110 # Get contents of tarball
Note:
See TracChangeset
for help on using the changeset viewer.
