Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!pacific.mps.ohio-state.edu!linac,att!oucsace!sadkins From: sadkins@oucsace.cs.OHIOU.EDU (Scott W. Adkins) Newsgroups: comp.unix.questions Subject: Re: awk script Keywords: awk, ps, kill Message-ID: <3124@oucsace.cs.OHIOU.EDU> Date: 18 Mar 91 23:20:53 GMT References: <1991Mar18.182106.2313@convex.com> Organization: Ohio University CS Dept., Athens Lines: 23 In article <1991Mar18.182106.2313@convex.com> tchrist@convex.COM (Tom Christiansen) writes: >: >:CMD='artemis' >:ME=`whoami` >:PROC=`ps -ef|grep /${CMD}| \ >:awk '{ $1 == ${ME} && $8 != "grep" $2 }' ` >:kill -HUP ${PROC} > >Two problems: > you don't want that slash in the grep command, > you can't depend on field counts on ps (on mine at least) If you are trying to parse the command from the 'ps' line, I merrily use current=substr($0,50) to get it all into a variable. The reason you can't depend on field counts is because some commands have spaces in them, such as 'vi file'. Others may be shell scripts or sub-processes that may start with '/bin/sh blah blah' or even 'sh -c blah blah'. It is really hard to count on field counts with 100% success. Scott Adkins sadkins@oucsace.cs.ohiou.edu (my .signature file has the flu...)