Path: utzoo!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!swrinde!cs.utexas.edu!sun-barr!newstop!texsun!convex!news From: tchrist@convex.COM (Tom Christiansen) Newsgroups: comp.unix.questions Subject: Re: awk script Keywords: awk, ps, kill Message-ID: <1991Mar18.182106.2313@convex.com> Date: 18 Mar 91 18:21:06 GMT References: Sender: news@convex.com (news access account) Reply-To: tchrist@convex.COM (Tom Christiansen) Organization: CONVEX Software Development, Richardson, TX Lines: 21 Nntp-Posting-Host: pixel.convex.com From the keyboard of drears@pica.army.mil: : I need to write a shell script that will allow users to kill all thier :processes associated that a program name. This script will run on a HP :9000/835, which is a SYSV Unix. : : I am having problems with the awk script in the following script :fragment: : :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) There is a nice zap script in the perl book, or available on uunet. --tom