- Timestamp:
- Jun 12, 2026, 2:47:49 PM (5 weeks ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-pstamp-20260421/pstamp/scripts/pstamp_parser_run.pl
r43048 r43052 13 13 use Getopt::Long qw( GetOptions ); 14 14 use File::Basename qw( basename dirname); 15 use Scalar::Util qw(looks_like_number);16 15 use File::Copy; 17 16 use POSIX qw( strftime ); 18 17 use Carp; 19 use IPC::Cmd 0.36 qw( can_run run);18 use IPC::Cmd 0.36 qw( can_run ); 20 19 21 20 use PS::IPP::Metadata::Config; … … 23 22 use PS::IPP::Metadata::List qw( parse_md_list ); 24 23 25 use PS::IPP::Config qw( :standard );24 use PS::IPP::Config qw( :standard ps_run ); 26 25 use PS::IPP::PStamp::RequestFile qw( :standard ); 27 26 … … 129 128 # if the uri is an http uri download the file 130 129 my $command = "$dsget --uri $uri --filename $new_uri --timeout 120"; 131 my ( $success, $error_msg, $full_buf, $stdout_buf, $stderr_buf ) = 132 run(command => $command, verbose => $verbose); 133 my $error_code = &parse_error_message ($success, $error_msg, $command); 130 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 131 ps_run(command => $command, verbose => $verbose); 134 132 unless ($success) { 135 my_die("Unable to perform $command error code: $error_code", $req_id, $error_code );133 my_die("Unable to perform $command error code: $error_code", $req_id, $error_code >> 8); 136 134 } 137 135 } elsif ($uri ne $new_uri) { … … 206 204 $command .= " -dbname $dbname" if $dbname; 207 205 $command .= " -dbserver $dbserver" if $dbserver; 208 my ( $success, $error_ msg, $full_buf, $stdout_buf, $stderr_buf ) =206 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 209 207 run(command => $command, verbose => $verbose); 210 my $error_code = &parse_error_message ($success, $error_msg, $command);211 208 unless ($success) { 212 209 die("Unable to perform $command error code: $error_code"); … … 230 227 231 228 my $command = "$parse_cmd"; 232 my ( $success, $error_msg, $full_buf, $stdout_buf, $stderr_buf ) = 233 run(command => $command, verbose => $verbose); 234 my $error_code = &parse_error_message ($success, $error_msg, $command); 229 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 230 ps_run(command => $command, verbose => $verbose); 235 231 236 232 # save the contents of stderr (if any) to a file. This is relevant if … … 258 254 } 259 255 } else { 260 $fault = $error_code ;256 $fault = $error_code >> 8; 261 257 } 262 258 } … … 275 271 $command .= " -dbserver $dbserver" if $dbserver; 276 272 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 277 run(command => $command, verbose => $verbose);273 ps_run(command => $command, verbose => $verbose); 278 274 unless ($success) { 279 275 die("Unable to perform $command error code: $error_code"); … … 324 320 $command .= " -dbserver $dbserver" if $dbserver; 325 321 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 326 run(command => $command, verbose => $verbose);322 ps_run(command => $command, verbose => $verbose); 327 323 unless ($success) { 328 324 die("Unable to perform $command error code: $error_code"); … … 330 326 exit $fault; 331 327 } 332 333 # if the program exited normally, the exit value is returned334 # if the program exited with a signal (abort, crash, etc), PS_EXIT_PROG_ERROR (4) is returned335 # if the program failed to run, -PS_EXIT_PROG_ERROR (-4) is returned336 sub parse_error_message {337 my $success = shift;338 my $error_msg = shift;339 my $command = shift;340 341 if ($success) { return 0; }342 343 print "raw error_msg: $error_msg\n";344 print "full command: $command\n";345 346 if (&looks_like_number($error_msg)) { return (($error_msg >> 8) or ($PS_EXIT_PROG_ERROR)); }347 348 # which of these match?349 my ($error_code) = $error_msg =~ m/exited with value (\d+)/;350 if (defined $error_code) { return $error_code; }351 352 ($error_code) = $error_msg =~ m/died with signal (\d+)/;353 # if (defined $error_code) { return (128 + $error_code); }354 if (defined $error_code) { return ($PS_EXIT_PROG_ERROR); }355 356 # probably failed to execute:357 return (-1*$PS_EXIT_PROG_ERROR);358 }359
Note:
See TracChangeset
for help on using the changeset viewer.
