problem with shell script

Samuel Martín Moro faust64 at gmail.com
Wed Jan 12 15:44:19 UTC 2011


On Wed, Jan 12, 2011 at 4:34 PM, Samuel Martín Moro <faust64 at gmail.com>wrote:

>
>
> On Wed, Jan 12, 2011 at 3:50 PM, Chad Kellerman <sunckell at gmail.com>wrote:
>
>> On Wed, Jan 12, 2011 at 9:01 AM, Frank Bonnet <f.bonnet at esiee.fr> wrote:
>>
>> > 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 !!!
>> >
>>
> ps ax | grep "[/]slapd " | wc -l
>
ps ax | awk '/[/]slapd /{n++} END{print n}'
sorry...

> may not fix the problem
> but still cleaner
>
>>  >
>> > Any info welcome !
>> >
>>
>> What's the name of your script?  Hope it's not slapd_check.sh that will
>> cause and extra count in the ps, cus it will count itself.
>>
>>
>> Chad
>>
>> >
>> > _______________________________________________
>> > freebsd-questions at freebsd.org mailing list
>> > http://lists.freebsd.org/mailman/listinfo/freebsd-questions
>> > To unsubscribe, send any mail to "
>> > freebsd-questions-unsubscribe at freebsd.org"
>> >
>>
>>
>>
>> --
>> A grasshopper walks into a bar and the bartender says "Hey, we have a
>> drink
>> named after you." And the grasshopper says "Really, You have a drink named
>> Murray?"
>> _______________________________________________
>> freebsd-questions at freebsd.org mailing list
>> http://lists.freebsd.org/mailman/listinfo/freebsd-questions
>> To unsubscribe, send any mail to "
>> freebsd-questions-unsubscribe at freebsd.org"
>>
>
>
>
> --
> Samuel Martín Moro
> {EPITECH.} 2011
> CamTrace S.A.S
>
> "Nobody wants to say how this works.
>  Maybe nobody knows ..."
>                       Xorg.conf(5)
>



-- 
Samuel Martín Moro
{EPITECH.} 2011
CamTrace S.A.S

"Nobody wants to say how this works.
 Maybe nobody knows ..."
                      Xorg.conf(5)


More information about the freebsd-questions mailing list