On Wed, Oct 11, 2000 at 07:17:35PM -0500, Aaron Schrab wrote:
> At 09:23 +0930 12 Oct 2000, Brian Salter-Duke <[EMAIL PROTECTED]> wrote:
> > On Wed, Oct 11, 2000 at 04:38:31PM -0700, Bruce J.A. Nourish wrote:
> > > > if ps -U $LOGNAME | grep realmutt > /dev/null
> > >
> > > Be careful about using grep to search the output of ps. For example
> > >
> > > $ ps ax | grep lemming
> > > 16004 tty1 S 0:00 grep lemming
> > >
> > > Y'see? Grep makes a match on its own process.
> >
> > It works OK on AIX 3.2.5 ps. If you add the -f flag it finds the grep
> > line, but it does'nt without it.
> >
> > OK, so maybe my script does'nt work on all systems, but it is worth
> > playing with to see if some set of ps flags works as required.
>
> Or you could just make a minor modification to the grep pattern:
>
> ps -U $LOGNAME | grep 'r[e]almutt' > /dev/null
>
> That way grep won't be able to match itself.
Clever! It works well.
Brian.
> --
> Aaron Schrab [EMAIL PROTECTED] http://www.execpc.com/~aarons/
> Besides, including <std_ice_cubes.h> is a fatal error on machines that
> don't have it yet. Bad language design, there... :-) --Larry Wall
--
Associate Professor Brian Salter-Duke (Brian Duke) [EMAIL PROTECTED]
School of Biological, Environmental and Chemical Sciences, SITE,
Northern Territory University, Darwin, NT 0909, Australia. Phone 08-89466702.
Fax 08-89466847 http://www.smps.ntu.edu.au/school/compchem.html