From owner-freebsd-questions@FreeBSD.ORG Fri Aug 24 00:51:02 2012 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 47DB1106566B for ; Fri, 24 Aug 2012 00:51:02 +0000 (UTC) (envelope-from frank@undermydesk.org) Received: from amazone.undermydesk.org (amazone.undermydesk.org [213.211.198.100]) by mx1.freebsd.org (Postfix) with ESMTP id EB7BB8FC19 for ; Fri, 24 Aug 2012 00:51:01 +0000 (UTC) Received: from amazone.undermydesk.org (localhost [127.0.0.1]) by amazone.undermydesk.org (Postfix) with ESMTP id C7BB5286E6C; Fri, 24 Aug 2012 02:51:00 +0200 (CEST) X-Virus-Scanned: amavisd-new at undermydesk.org Received: from amazone.undermydesk.org ([213.211.198.100]) by amazone.undermydesk.org (amazone.undermydesk.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id X4_2t1UMVipj; Fri, 24 Aug 2012 02:50:55 +0200 (CEST) Received: from [192.168.0.74] (p57AE7096.dip.t-dialin.net [87.174.112.150]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (Client did not present a certificate) by amazone.undermydesk.org (Postfix) with ESMTPSA id 51CFD286E5B; Fri, 24 Aug 2012 02:50:55 +0200 (CEST) Message-ID: <5036CFE9.1010602@undermydesk.org> Date: Fri, 24 Aug 2012 02:50:49 +0200 From: Frank Reppin User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:14.0) Gecko/20120713 Thunderbird/14.0 MIME-Version: 1.0 To: Jack Stone References: <5036B542.1040509@sage-american.com> <5036B897.1050101@undermydesk.org> <5036C751.20704@sage-american.com> In-Reply-To: <5036C751.20704@sage-american.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: FreeBSD Questions Subject: Re: small script help 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: Fri, 24 Aug 2012 00:51:02 -0000 On 24.08.2012 02:14, Jack Stone wrote: > Thanks, I tried that but pgrep only displayed the PIDs. I guess I wasn't > using proper switches. Yes - and this should be enough. If pgrep returns PIDs - then this is the same as 'true' in your 'if' condition - if it returns nothing, the 'else' part is executed: #!/bin/sh # * example for Jack with amavisd instead of apache # * the ^ means 'match from the beginning' # * so your content for PROCESS_PATTERN would be # PROCESS_PATTERN="^/usr/local/sbin/httpd" # because ps -ax would show you this in the # COMMAND row PROCESS_PATTERN="^/usr/local/sbin/amavisd" PGREP="/bin/pgrep" if ${PGREP} -q -j none -f ^${PROCESS_PATTERN}; then echo -e "OK" else echo -e "FAIL" fi hth, Frank Reppin -- 43rd Law of Computing: Anything that can go wr fortune: Segmentation violation -- Core dumped