system() not having command exit status

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Tim F.

    system() not having command exit status

    Racked my brain and searched the archives but came up empty on both
    instances. :^()

    I have a script that is grabbing a pid out of a file and then using
    the exit status of `ps -p` to determine if the process is running. I
    don't have any of the Proc modules installed so this is the quickest
    way I could come up with. The problem is that system("ps -p $pid") ==
    0 is always true. I can run the command at the unix shell and it
    comes back with $? == 1.

    My next step is to just create a hash of all the running pids and test
    against that. Thanks for the help.

    Tim

    Code Snippit
    foreach $Username (@master_list) {
    if (-e "/home/$Username/dynamo/home/servers/$Username/logs/dynamo.pid")
    {
    $fh->open("< /home/$Username/dynamo/home/servers/$Username/logs/dynamo.pid")
    ;
    $pid = <$fh>;
    }else{
    next
    }
    $ENV{DYNAMO_HOM E} = "/home/$Username/dynamo/home";

    # Now we check to see if that PID is a valid process and if so issue
    the
    # stopDynamo command for that particular users instance;

    $cmd = "ps -p $pid >/dev/null";
    $kill_cmd = "/home/$Username/dynamo/home/bin/stopDynamo $Username
    -kill";
    #system($cmd) == 0 and system($kill_cm d);
    print system($cmd),"\ n";
    } # End foreach
  • Joe Smith

    #2
    Re: system() not having command exit status

    Tim F. wrote:
    [color=blue]
    > I have a script that is grabbing a pid out of a file and then using
    > the exit status of `ps -p` to determine if the process is running. I
    > don't have any of the Proc modules installed so this is the quickest
    > way I could come up with.[/color]

    perldoc -f kill ;# Look for the paragraph with "zero"
    -Joe
    --
    I love my TiVo - http://www.inwap.com/u/joe/tivo/

    Comment

    Working...