killing processes thru' C programs

Jonathan I. Kamens jik at athena.mit.edu
Wed May 1 14:29:29 AEST 1991


In article <878 at systech.bjorn.COM>, dan at systech.bjorn.COM (Dan Gill) writes:
|> if you use ps uxc | grep name | awk '{print $2}' the only thing displayed
|> is the pid of the processes name.  You should be careful for if you used
|> vi as the name, there could be some unhappy campers in your KOA.

  There are two problems with what you have suggested.

  First of all, there's no reason to use two processes, when awk has regular
expression capabilities.  Change what you said to:

	ps uxc | awk '/name/ {print $2}'

  Second, as someone else has pointed out in another message, if you use 'ps
uxc', then shell scripts are listed as "sh" instead of as the name of the
script, which means you can't kill scripts using this method.  Given that I
need to do that at times, it makes more sense to use what I suggested (i.e.
"ps ux" and search with awk '/name/ && !/awk/ {print $2}') than it does to use
"ps uxc".

-- 
Jonathan Kamens			              USnail:
MIT Project Athena				11 Ashford Terrace
jik at Athena.MIT.EDU				Allston, MA  02134
Office: 617-253-8085			      Home: 617-782-0710



More information about the Comp.unix.questions mailing list