Newsgroups: comp.unix.questions
Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!ispd-newsserver!garden!weimer
From: weimer@garden.kodak.COM (Gary Weimer (588-0953))
Subject: Re: awk script problems <sigh>
Message-ID: <1991Mar20.191306.4849@ssd.kodak.com>
Sender: news@ssd.kodak.com
Reply-To: weimer@ssd.kodak.com
Organization: Eastman Kodak Co.; Rochester, NY
References:  <SHAWN.91Mar20141448@litsun.epfl.ch>
Distribution: comp
Date: Wed, 20 Mar 91 19:13:06 GMT


In article <SHAWN.91Mar20141448@litsun.epfl.ch>, shawn@litsun.epfl.ch
(Shawn Koppenhoefer) writes:
...
|> So far I've got: ps -aux | grep xdm | grep -v grep | egrep "0 (xdm)"
|> which gives me the line:
|>     root       122  0.0  0.0   88    0 ?  IW   12:43   0:00 xdm
|> if the xdm process exists. Now, I figured that if I passed this into
|> the following awk script the /tmp/xdm-pid file would be erased. but
|> instead I get an error... what's wrong?!
|> -----------------my executable file looks like the following
|> 
|> awk '
|> $11 == "xdm" { touch thisfile }
|> '
|> 
|> I use "touch thisfile" to see if the file "thisfile" is created, but
|> it never is! (later I'll replace "touch thisfile" with "rm
|> /tmp/xdm-pid"

It would help if you told us what the error is...

If you really have the awk command spread over three lines, that could
be the cause of your error.
touch is not an awk command, so you can't use it inside the curly
brackets (rm is not an awk command either).
Why do you even need awk? If the above ps line returns something, the
process is still running; otherwise, it has died. So...

#!/bin/csh -fb
set x=`ps -aux | grep xdm | grep -v grep`
if ("$x" == "") rm /tmp/xdm-pid       # remove file when xdm dies

What was the last egrep for, anyway???

weimer@ssd.kodak.com ( Gary Weimer )
