Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Perl (http://www.velocityreviews.com/forums/f17-perl.html)
-   -   system() not having command exit status (http://www.velocityreviews.com/forums/t24798-system-not-having-command-exit-status.html)

Tim F. 01-29-2004 04:14 PM

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_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

Joe Smith 01-29-2004 08:42 PM

Re: system() not having command exit status
 
Tim F. wrote:

> 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
--
I love my TiVo - http://www.inwap.com/u/joe/tivo/


All times are GMT. The time now is 04:13 AM.

Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57