[plug] problem with script

Jon Miller jlmiller at mmtnetworks.com.au
Mon Aug 25 19:26:59 WST 2003


Correct me if I'm wrong, but using the following does generate a value of the variable by using ` `.  What I was getting was 8-10 PID listings.  Because I only require 1 listing I then added the following to the script:
function fmlstat()
{
vMMSTAT="echo $MMSTAT | awk '{print $1}"
echo $vMMSTAT
}
I run this function before the "if" statement

I'm now getting:
# ./postfixstatchk.sh
./postfixstatchk.sh: line 54: syntax error: unexpected end of file


Line 54 is the last line of the script and it ends with a "fi" which is part of a "if" statement.

JLM

Latest changes to script:
MTAPATH=/usr/sbin
MTA=postfix
MMPATH=/usr/local/sophos/mmsmtp-1.2.2/Linux-x86/bin
MMSP='mmsmtpd -terminate'
MMST='mmsmtpd -start'
MLSTAT=`pgrep -U postfix`
MMSTAT=`pgrep -u root mmsmtp.out`
#
#
# function to get a single figure from the mail monitor variable
function fmmstat()
{
vMMSTAT=`echo $MMSTAT | awk '{print $1}'`
echo $vMMSTAT
}
# function to get single figure from the mail variable
function fmlstat()
{
vMLSTAT=`echo $MLSTAT | awk '{print $1}'`
echo $vMLSTAT
#
# function to restart MM and postfix
function mmpf()
{
        $MTAPATH/$MTA stop
        $MMPATH/$MMSP
        $MMPATH/$MMST
        $MTAPATH/$MTA start
}

# check for existence of data
fmmstat
if [ "$vMMSTAT" -lt 1 ]; then
   mmpf
fi
fmlstat
if [ "$vMLSTAT" -lt 1 ]; then
   mmpf
fi


Jon L. Miller, MCNE, CNS
Director/Sr Systems Consultant
MMT Networks Pty Ltd
http://www.mmtnetworks.com.au

"I don't know the key to success, but the key to failure
 is trying to please everybody." -Bill Cosby



>>> devenish at guild.uwa.edu.au 6:08:52 PM 25/08/2003 >>>
In message <sf4a511b.067 at mmtnetworks.com.au>
on Mon, Aug 25, 2003 at 06:10:31PM +0800, Jon  Miller wrote:
> MMSTAT=`pgrep -u root mmsmtp.out`
[...]
> if [ "$MMSTAT" -lt 1 ]; then

BTW the above will run pgrep when the variable is declared, not during
the "if" statement. To resolve this, I would use this, instead:

> MMSTAT=(pgrep -u root mmsmtp.out >& /dev/null)
> 
> if $MMSTAT; then

This is for zsh, though. Does anyone know a POSIX equivalent?







More information about the plug mailing list