Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 12 Jan 2011 09:00:12 -0700 (MST)
From:      Warren Block <wblock@wonkity.com>
To:        =?ISO-8859-15?Q?Samuel_Mart=EDn_Moro?= <faust64@gmail.com>
Cc:        Chad Kellerman <sunckell@gmail.com>, Frank Bonnet <f.bonnet@esiee.fr>, freebsd-questions@freebsd.org
Subject:   Re: problem with shell script
Message-ID:  <alpine.BSF.2.00.1101120858390.87818@wonkity.com>
In-Reply-To: <AANLkTikcH9jjNNf-1vwTzgxekH5bp%2BdXnnvh923f1NcM@mail.gmail.com>
References:  <4D2DB449.6070901@esiee.fr> <AANLkTimHU7kQXM0agHsfz=hHn2zuBuL4xihDxUWo3%2BvB@mail.gmail.com> <AANLkTikcH9jjNNf-1vwTzgxekH5bp%2BdXnnvh923f1NcM@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Wed, 12 Jan 2011, Samuel Mart?n Moro wrote:

> On Wed, Jan 12, 2011 at 3:50 PM, Chad Kellerman <sunckell@gmail.com> wrote:
>
>> On Wed, Jan 12, 2011 at 9:01 AM, Frank Bonnet <f.bonnet@esiee.fr> wrote:
>>
>>> 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 !!!
>>
> ps ax | grep "[/]slapd " | wc -l
> may not fix the problem
> but still cleaner

ps axc | grep slapd | wc -l

is a little neater.



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