From owner-freebsd-questions@FreeBSD.ORG Thu Jan 13 13:12:25 2011 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 2C710106564A for ; Thu, 13 Jan 2011 13:12:25 +0000 (UTC) (envelope-from jcigar@ulb.ac.be) Received: from mxin.ulb.ac.be (mxin.ulb.ac.be [164.15.128.112]) by mx1.freebsd.org (Postfix) with ESMTP id BC1CB8FC1C for ; Thu, 13 Jan 2011 13:12:24 +0000 (UTC) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AuIBACOCLk2kD30E/2dsb2JhbAAMg3ySK4kytDuODYRYdASKHIQK Received: from bebif01.ulb.ac.be (HELO [10.0.0.194]) ([164.15.125.4]) by smtp.ulb.ac.be with ESMTP; 13 Jan 2011 14:12:23 +0100 Message-ID: <4D2EFA36.4020703@ulb.ac.be> Date: Thu, 13 Jan 2011 14:12:22 +0100 From: Julien Cigar Organization: Belgian Biodiversity Platform User-Agent: Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.9.1.10) Gecko/20100621 Thunderbird/3.0.5 MIME-Version: 1.0 To: freebsd-questions@freebsd.org References: <4d2ef151.4310df0a.25b7.0199@mx.google.com> In-Reply-To: <4d2ef151.4310df0a.25b7.0199@mx.google.com> Content-Type: multipart/mixed; boundary="------------010101080308040104050206" X-Content-Filtered-By: Mailman/MimeDel 2.1.5 Subject: Re: problem with shell script X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 Jan 2011 13:12:25 -0000 This is a multi-part message in MIME format. --------------010101080308040104050206 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit just use: pgrep "slapd" On 01/12/2011 15:17, four.harrisons@googlemail.com 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 !!! > > > Any info welcome ! > > _______________________________________________ > freebsd-questions@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-questions > To unsubscribe, send any mail to "freebsd-questions-unsubscribe@freebsd.org" > > _______________________________________________ > freebsd-questions@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-questions > To unsubscribe, send any mail to "freebsd-questions-unsubscribe@freebsd.org" -- No trees were killed in the creation of this message. However, many electrons were terribly inconvenienced. --------------010101080308040104050206--