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_server_status

    r43048 r43052  
    77
    88#use DBI;
    9 use IPC::Cmd 0.36 qw( can_run run );
     9use IPC::Cmd 0.36 qw( can_run );
    1010#use PS::IPP::Metadata::Config;
    11 use PS::IPP::Config 1.01 qw( :standard );
     11use PS::IPP::Config 1.01 qw( :standard ps_run );
    1212
    1313use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt );
    1414use Pod::Usage qw( pod2usage );
    15 use Scalar::Util qw(looks_like_number);
    1615
    1716my ($rundir, $workdir, $verbose, $save_temps);
     
    7170    my $serverRunning = 0;
    7271    my $command = "$pantasks_client < $pantasks_script";
    73     my  ( $success, $error_msg, $full_buf, $stdout_buf, $stderr_buf ) =
    74         run(command => $command, verbose => $verbose);
    75     my $error_code = &parse_error_message ($success, $error_msg, $command);
     72    my  ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     73        ps_run(command => $command, verbose => $verbose);
    7674    if ($success) {
    7775        $serverRunning = 1;
    7876    } else {
    79         $error_code = ($error_code or 1);
     77        $error_code = (($error_code >> 8) or 1);
    8078        if ($error_code == 12 || $error_code == 13) {
    8179            print "Postage Stamp Server is not running\n<br>";
     
    206204
    207205exit 0;
    208 
    209 # if the program exited normally, the exit value is returned
    210 # if the program exited with a signal (abort, crash, etc), PS_EXIT_PROG_ERROR (4) is returned
    211 # if the program failed to run, -PS_EXIT_PROG_ERROR (-4) is returned
    212 sub parse_error_message {
    213     my $success = shift;
    214     my $error_msg = shift;
    215     my $command = shift;
    216 
    217     if ($success) { return 0; }
    218 
    219     print "raw error_msg: $error_msg\n";
    220     print "full command: $command\n";
    221 
    222     if (&looks_like_number($error_msg)) { return (($error_msg >> 8) or ($PS_EXIT_PROG_ERROR)); }
    223        
    224     # which of these match?
    225     my ($error_code) = $error_msg =~ m/exited with value (\d+)/;
    226     if (defined $error_code) { return $error_code; }
    227    
    228     ($error_code) = $error_msg =~ m/died with signal (\d+)/;
    229 #   if (defined $error_code) { return (128 + $error_code); }
    230     if (defined $error_code) { return ($PS_EXIT_PROG_ERROR); }
    231    
    232     # probably failed to execute:
    233     return (-1*$PS_EXIT_PROG_ERROR);
    234 }
Note: See TracChangeset for help on using the changeset viewer.