*BSD News Article 80113


Return to BSD News archive

Path: euryale.cc.adfa.oz.au!newshost.carno.net.au!harbinger.cc.monash.edu.au!munnari.OZ.AU!news.ecn.uoknor.edu!news.wildstar.net!news.ececs.uc.edu!news.kei.com!news.texas.net!www.nntp.primenet.com!nntp.primenet.com!dispatch.news.demon.net!demon!awfulhak.demon.co.uk!awfulhak.demon.co.uk!usenet
From: brian@anorak.coverform.lan (Brian Somers)
Newsgroups: comp.unix.bsd.freebsd.misc
Subject: Re: Why does this not work.  I get an error can not find for, do, in, while.
Date: 6 Oct 1996 22:41:13 GMT
Organization: Coverform Ltd.
Lines: 42
Message-ID: <539ci9$im@anorak.coverform.lan>
References: <01bbb484$da51d760$63c4abc7@glen>
Reply-To: brian@awfulhak.demon.co.uk
NNTP-Posting-Host: anorak.coverform.lan
X-NNTP-Posting-Host: awfulhak.demon.co.uk
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
X-Newsreader: knews 0.9.8

In article <01bbb484$da51d760$63c4abc7@glen>,
	"Glen" <gi143@cybercomm.net> writes:
> Can someone please tell me why this does not work.
> I'm useing the korn shell and the C shell.  I try to do a man if , for,
> while nothing there.  Is there some package I have to install.  Thank for
> you help
> 
> for user in $*
> do
> echo $user
> 	ps -aux $user |  cut -c9-14 | grep -v PID| while read i
> 	do
> 	kill -15 $i
> 	echo $i
> 	done
> 	
> 	ps -aux $user |  cut -c9-14 | grep -v PID| while read i
> 	do
> 	kill -9 $i
> 	echo $i
> 	done
> done

Well, a "man ps" would be a good start ;)

Try the following:

#! /bin/sh
getpids()
{
    ps -axouser,pid | fgrep "$1 " | sed 's/.* //'
}
for user
do
    kill `getpids $user`
    sleep 5			# give 'em time !
    kill -9 `getpids $user`
done

-- 
Brian <brian@awfulhak.demon.co.uk>
Don't _EVER_ lose your sense of humour....