From owner-freebsd-questions@FreeBSD.ORG Mon Dec 12 16:04:54 2005 Return-Path: X-Original-To: freebsd-questions@freebsd.org Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id E28C916A41F for ; Mon, 12 Dec 2005 16:04:54 +0000 (GMT) (envelope-from e.schuele@computer.org) Received: from rwcrmhc11.comcast.net (rwcrmhc11.comcast.net [204.127.198.35]) by mx1.FreeBSD.org (Postfix) with ESMTP id 59C1243D55 for ; Mon, 12 Dec 2005 16:04:54 +0000 (GMT) (envelope-from e.schuele@computer.org) Received: from [208.206.151.59] (host59.gtisd.com[208.206.151.59]) by comcast.net (rwcrmhc11) with ESMTP id <2005121216045301300bgfk6e>; Mon, 12 Dec 2005 16:04:53 +0000 Message-ID: <439D9FA3.7030603@computer.org> Date: Mon, 12 Dec 2005 10:04:51 -0600 From: Eric Schuele User-Agent: Mozilla Thunderbird 1.0.7 (X11/20051204) X-Accept-Language: en-us, en MIME-Version: 1.0 To: FreeBSD Questions Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: grep'ping the ps output.... 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: Mon, 12 Dec 2005 16:04:55 -0000 Hello, I am sure this is quite trivial, but... I have need to determine if an app (firefox, or anything really) is already running before I perform some action. So I grep the ps output. However sometimes (many times) that which I'm searching for is present in the output because I am presently grep'ing for it. But it is not always there. It seems to be a bit inconsistent. (See below). I was wondering if someone could explain why it is sometimes there and not other times. And how I should correctly go about detecting if the process is running before I perform my action. Thanks, Eric %ps | grep firefox^M^M 703 v0 I 0:00.00 /bin/sh /usr/X11R6/bin/firefox^M 722 v0 I 0:00.00 /bin/sh /usr/X11R6/lib/firefox/run-mozilla.sh /usr/X1^ M 734 v0 S 0:10.92 /usr/X11R6/lib/firefox/firefox-bin^M %ps | grep firefox^M^M 703 v0 I 0:00.00 /bin/sh /usr/X11R6/bin/firefox^M 722 v0 I 0:00.00 /bin/sh /usr/X11R6/lib/firefox/run-mozilla.sh /usr/X1^ M 734 v0 S 0:10.92 /usr/X11R6/lib/firefox/firefox-bin^M 1230 p1 RV 0:00.00 grep firefox (csh)^M %^M^M %ps | grep firefox^M^M 703 v0 I 0:00.00 /bin/sh /usr/X11R6/bin/firefox^M 722 v0 I 0:00.00 /bin/sh /usr/X11R6/lib/firefox/run-mozilla.sh /usr/X1^ M 734 v0 S 0:10.92 /usr/X11R6/lib/firefox/firefox-bin^M 1232 p1 R+ 0:00.00 grep firefox^M %ps | grep firefox^M^M 703 v0 I 0:00.00 /bin/sh /usr/X11R6/bin/firefox^M 722 v0 I 0:00.00 /bin/sh /usr/X11R6/lib/firefox/run-mozilla.sh /usr/X1^ M 734 v0 S 0:10.92 /usr/X11R6/lib/firefox/firefox-bin^M %ps | grep firefox^M^M 703 v0 I 0:00.00 /bin/sh /usr/X11R6/bin/firefox^M 722 v0 I 0:00.00 /bin/sh /usr/X11R6/lib/firefox/run-mozilla.sh /usr/X1^ M 734 v0 S 0:10.92 /usr/X11R6/lib/firefox/firefox-bin^M 1236 p1 R+ 0:00.00 grep firefox^M %ps | grep firefox^M^M 703 v0 I 0:00.00 /bin/sh /usr/X11R6/bin/firefox^M 722 v0 I 0:00.00 /bin/sh /usr/X11R6/lib/firefox/run-mozilla.sh /usr/X1^ M 734 v0 S 0:10.92 /usr/X11R6/lib/firefox/firefox-bin^M -- Regards, Eric