[plug] problem with script
James Devenish
devenish at guild.uwa.edu.au
Tue Aug 26 09:36:33 WST 2003
In message <sf4a7734.011 at mmtnetworks.com.au>
on Mon, Aug 25, 2003 at 08:52:56PM +0800, Jon Miller wrote:
> jlm> output from running following command:
> MLSTAT=`pgrep -U postfix`
> gateway:~# echo $MLSTAT | head -1
> 2118 3100 3137
My mistake -- you are right, that is the POSIX behaviour. I have my
shell configured not to munge the output of command substitution,
so I would get:
# echo $MLSTAT
2118
3110
3137
> 2/ You don't really need pgrep's output at all. If I understand your
> usage correctly, you simply want to know whether there are any
> mmsmtp.out processes.
> jlm> yes I need to know if there are any processes running, but this
> process has anywhere between 1-12 processes running so I only need the
> results to list one.
Sure. The specific new concept I was trying to get across is that you
actually don't need to know the PID of one of the processes, you only
seem to need to know "true" or "false" in response to the question "are
there any such processes". Thus, you don't need to do any text
processing. But more to the point, I don't think your script does what
you intend (but I don't know exactly what you want, of course). In
particular:
> if [ "$vMMSTAT" -lt 1 ]; then
The above line means "if $vMMSTAT contains a numerical value and the
value is less than one". Does it behave right when $vMMSTAT is empty?
I think you meant:
> if [ -z "$vMMSTAT" ]; then
This means "is $vMMSTAT is empty". Then, it can be simplified to:
> if [ -z "$MMSTAT" ]; then
That is, there doesn't appear to be a need to convert $MMSTAT to
$vMMSTAT.
Furthermore:
> fmmstat
> if [ "$vMMSTAT" -lt 1 ]; then
> mmpf
> fi
> fmlstat
> if [ "$vMLSTAT" -lt 1 ]; then
> mmpf
> fi
Do you need the fmlstat to be performed after the first mmpf clause?
When I look at fmlstat, it uses $MLSTAT. It does not perform any test:
it simply uses the old value of $MLSTAT. And the value of $MLSTAT was
set on line 6. So the fate of the second mmpf (the one that currently
depends on $vMLSTAT) will be determined prior to the first mmpf (the one
that currently depends on $vMMSTAT).
More information about the plug
mailing list