IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jun 12, 2026, 2:47:49 PM (7 weeks ago)
Author:
eugene
Message:

convert the IPC::Cmd run calls to ps_run to handle inconsistent behavior between IPC:Cmd versions pre- and post-0.40

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-pstamp-20260421/pstamp/scripts/pstamp_queue_cleanup.pl

    r43048 r43052  
    66use warnings;
    77
    8 use PS::IPP::Config 1.01 qw( :standard );
    9 use IPC::Cmd 0.36 qw( can_run run );
     8use PS::IPP::Config 1.01 qw( :standard ps_run );
     9use IPC::Cmd 0.36 qw( can_run );
    1010use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt );
    1111use Pod::Usage qw( pod2usage );
    12 use Scalar::Util qw(looks_like_number);
    1312
    1413my $verbose;
     
    7069
    7170my $command = "$pstamptool -updatereq -set_state goto_cleaned -state stop -timestamp_end $timestamp_end";
    72 my  ( $success, $error_msg, $full_buf, $stdout_buf, $stderr_buf ) =
    73     run(command => $command, verbose => $verbose);
    74 my $error_code = &parse_error_message ($success, $error_msg, $command);
     71my  ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     72    ps_run(command => $command, verbose => $verbose);
    7573unless ($success) {
    76     $error_code = ($error_code or 1);
     74    $error_code = (($error_code >> 8) or 1);
    7775    warn("$command failed. exit status: $error_code");
    7876    exit $error_code;
     
    8280exit 0;
    8381
    84 # if the program exited normally, the exit value is returned
    85 # if the program exited with a signal (abort, crash, etc), PS_EXIT_PROG_ERROR (4) is returned
    86 # if the program failed to run, -PS_EXIT_PROG_ERROR (-4) is returned
    87 sub parse_error_message {
    88     my $success = shift;
    89     my $error_msg = shift;
    90     my $command = shift;
    91 
    92     if ($success) { return 0; }
    93 
    94     print "raw error_msg: $error_msg\n";
    95     print "full command: $command\n";
    96 
    97     if (&looks_like_number($error_msg)) { return (($error_msg >> 8) or ($PS_EXIT_PROG_ERROR)); }
    98        
    99     # which of these match?
    100     my ($error_code) = $error_msg =~ m/exited with value (\d+)/;
    101     if (defined $error_code) { return $error_code; }
    102    
    103     ($error_code) = $error_msg =~ m/died with signal (\d+)/;
    104 #   if (defined $error_code) { return (128 + $error_code); }
    105     if (defined $error_code) { return ($PS_EXIT_PROG_ERROR); }
    106    
    107     # probably failed to execute:
    108     return (-1*$PS_EXIT_PROG_ERROR);
    109 }
Note: See TracChangeset for help on using the changeset viewer.