Changeset 18233
- Timestamp:
- Jun 20, 2008, 9:36:26 AM (18 years ago)
- File:
-
- 1 edited
-
trunk/pstamp/scripts/pstamp_webrequest.pl (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/pstamp/scripts/pstamp_webrequest.pl
r16974 r18233 11 11 # the selected "input" uris are listed on stdout. 12 12 # 13 # Note: Despite the name there nothing really web specific about this program.13 # Note: Despite the name there nothing particularly web specific about this program. 14 14 # 15 15 ### … … 18 18 use strict; 19 19 20 my $verbosity = 0; 20 use Getopt::Long qw( GetOptions ); 21 use Sys::Hostname; 21 22 22 use Sys::Hostname;23 23 my $host = hostname(); 24 my $verbose = 0; 25 my $dbname; 24 26 25 if ($verbosity) { 27 GetOptions( 28 'verbose' => \$verbose, 29 'dbname=s' => \$dbname, 30 ); 31 32 33 34 if ($verbose) { 26 35 print "\n\n"; 27 36 print "Starting script $0 on $host\n\n"; 28 37 } 38 29 39 30 40 use IPC::Cmd 0.36 qw( can_run run ); … … 65 75 66 76 my $cur_dir = getcwd(); 67 my $request_file = "$cur_dir/request_file.$$.fits"; 77 my $request_name = "web" . get_webreq_num(); 78 my $request_file = "$cur_dir/$request_name.fits"; 68 79 { 69 my $command = "$pstamprequest $request_file @ARGV";80 my $command = "$pstamprequest -request_name $request_name $request_file @ARGV"; 70 81 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 71 run(command => $command, verbose => $verbos ity);82 run(command => $command, verbose => $verbose); 72 83 unless ($success) { 73 84 print STDERR @$stderr_buf; … … 82 93 ### 83 94 my $command = "$pstampparse $request_file"; 95 $command .= " -dbname $dbname" if $dbname; 84 96 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 85 run(command => $command, verbose => $verbos ity);97 run(command => $command, verbose => $verbose); 86 98 87 99 if ($success) { … … 98 110 { 99 111 100 my $command = "$pstamptool -addreq -uri $request_file -out_fileset \'pstampresults/web\$REQ_ID\'"; 112 my $command = "$pstamptool -addreq -uri $request_file -out_fileset \'pstampresults/$request_name'"; 113 $command .= " -dbname $dbname" if $dbname; 101 114 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 102 run(command => $command, verbose => $verbos ity);115 run(command => $command, verbose => $verbose); 103 116 unless ($success) { 104 117 print STDERR @$stderr_buf; … … 111 124 112 125 exit 0; 126 127 # Temporary hack 128 # webrequest number is stored in a file in the current directory 129 # 130 sub get_webreq_num 131 { 132 my $filename = "./webreq_num.txt"; 133 if (! open IN, "+< $filename" ) { 134 my $initial_num = 1; 135 open IN, "> $filename" or die "can't open request $filename"; 136 print IN "$initial_num\n" or die "failed to initialize $filename"; 137 close IN; 138 return $initial_num; 139 } 140 141 my $webreq_num = <IN>; 142 chomp $webreq_num; 143 144 print STDERR "$webreq_num\n"; 145 146 my $next = $webreq_num + 1; 147 truncate IN, 0; 148 seek IN, 0, 0; 149 print IN "$next\n"; 150 151 close IN; 152 return $webreq_num; 153 }
Note:
See TracChangeset
for help on using the changeset viewer.
