Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 13 Jan 2011 14:45:04 -0600 (CST)
From:      Robert Bonomi <bonomi@mail.r-bonomi.com>
To:        f.bonnet@esiee.fr, freebsd-questions@freebsd.org
Subject:   Re: problem with shell script
Message-ID:  <201101132045.p0DKj43V027817@mail.r-bonomi.com>
In-Reply-To: <4D2DB449.6070901@esiee.fr>

next in thread | previous in thread | raw e-mail | index | archive | help

> Date: Wed, 12 Jan 2011 15:01:45 +0100
> From: Frank Bonnet <f.bonnet@esiee.fr>
> Subject: problem with shell script
>
> Hello
>
> I'm in trouble with a simple shell script that give erroneous value when 
> running ...
>
> If I run commands interactively everything runs well
>
>  > ps ax | grep slapd | grep -v grep | wc -l
>        1
>
> If I run in the following shell script :
>
> #!/bin/sh
> SD=0 SD=`ps -ax | grep slapd | grep -v grep | wc -l` echo $SD
>
> the result is 3 !!!

Advice: don't try to 'out-think' the machine -- make it _show_ you what it
 is doing.

Change the script to:
   SD=`ps -ax | grep slapd | grep -v grep | tee /dev/tty | wc -l` echo $SD


I suspect thet the -name- of the script file has 'slapd' in it.






Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201101132045.p0DKj43V027817>