From owner-freebsd-questions@FreeBSD.ORG Mon Dec 12 17:00:06 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 4DE1B16A41F for ; Mon, 12 Dec 2005 17:00:06 +0000 (GMT) (envelope-from e.schuele@computer.org) Received: from rwcrmhc12.comcast.net (rwcrmhc13.comcast.net [204.127.198.39]) by mx1.FreeBSD.org (Postfix) with ESMTP id C0A5A43D72 for ; Mon, 12 Dec 2005 16:59: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 (rwcrmhc13) with ESMTP id <2005121216595101500479gne>; Mon, 12 Dec 2005 16:59:51 +0000 Message-ID: <439DAC84.7000601@computer.org> Date: Mon, 12 Dec 2005 10:59:48 -0600 From: Eric Schuele User-Agent: Mozilla Thunderbird 1.0.7 (X11/20051204) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Alex Zbyslaw References: <439D9FA3.7030603@computer.org> <439DA275.70404@dial.pipex.com> In-Reply-To: <439DA275.70404@dial.pipex.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: FreeBSD@keyslapper.net, FreeBSD Questions Subject: Re: 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 17:00:06 -0000 Alex Zbyslaw wrote: > Eric Schuele wrote: > >> 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. >> > ps | egrep firefox | egrep -v egrep > Thanks guys. Yes... both solutions do fix the problem. Hmm... guess I should've looked before I lept. I assumed the processes were run in order by the shell... however it appears all are started simultaneously as a group. > I can't explain exactly why. It's clearly a timing thing. I guess if > the ps runs quickly enough then perhaps the grep hasn't actually been > started by the shell. > Or if ps iterates over something, then maybe the > grep appears in a part of the list that has already been looked at by ps. > > --Alex > > > _______________________________________________ > 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" > -- Regards, Eric