awk script problems <sigh>

Gary Weimer 588-0953 weimer at garden.kodak.COM
Thu Mar 21 05:13:06 AEST 1991


In article <SHAWN.91Mar20141448 at litsun.epfl.ch>, shawn at 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 at ssd.kodak.com ( Gary Weimer )



More information about the Comp.unix.questions mailing list