system() not having command exit status

T

Tim F.

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_HOME} = "/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_cmd);
print system($cmd),"\n";
} # End foreach
 
J

Joe Smith

Tim said:
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.

perldoc -f kill ;# Look for the paragraph with "zero"
-Joe
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top