IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jun 12, 2026, 2:47:49 PM (5 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_save_server_status.pl

    r43048 r43052  
    77use warnings;
    88
    9 use PS::IPP::Config 1.01 qw( :standard );
    10 use IPC::Cmd 0.36 qw( can_run run );
     9use PS::IPP::Config 1.01 qw( :standard ps_run );
     10use IPC::Cmd 0.36 qw( can_run );
    1111use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt );
    1212use Pod::Usage qw( pod2usage );
    13 use Scalar::Util qw(looks_like_number);
    1413
    1514my $updatelink;
     
    6463my $command = "pstamp_server_status --workdir $pstamp_workdir > $file";
    6564#my $command = "pstamp_server_status > $file";
    66 my  ( $success, $error_msgo, $full_buf, $stdout_buf, $stderr_buf ) =
    67     run(command => $command, verbose => $verbose);
    68 my $error_code = &parse_error_message ($success, $error_msg, $command);
     65my  ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     66    ps_run(command => $command, verbose => $verbose);
    6967unless ($success) {
    70     $error_code = ($error_code or 1);
     68    $error_code = (($error_code >> 8) or 1);
    7169    warn("$command failed. exit status: $error_code");
    7270    exit $error_code;
     
    8280
    8381exit 0;
    84 
    85 # if the program exited normally, the exit value is returned
    86 # if the program exited with a signal (abort, crash, etc), PS_EXIT_PROG_ERROR (4) is returned
    87 # if the program failed to run, -PS_EXIT_PROG_ERROR (-4) is returned
    88 sub parse_error_message {
    89     my $success = shift;
    90     my $error_msg = shift;
    91     my $command = shift;
    92 
    93     if ($success) { return 0; }
    94 
    95     print "raw error_msg: $error_msg\n";
    96     print "full command: $command\n";
    97 
    98     if (&looks_like_number($error_msg)) { return (($error_msg >> 8) or ($PS_EXIT_PROG_ERROR)); }
    99        
    100     # which of these match?
    101     my ($error_code) = $error_msg =~ m/exited with value (\d+)/;
    102     if (defined $error_code) { return $error_code; }
    103    
    104     ($error_code) = $error_msg =~ m/died with signal (\d+)/;
    105 #   if (defined $error_code) { return (128 + $error_code); }
    106     if (defined $error_code) { return ($PS_EXIT_PROG_ERROR); }
    107    
    108     # probably failed to execute:
    109     return (-1*$PS_EXIT_PROG_ERROR);
    110 }
Note: See TracChangeset for help on using the changeset viewer.