home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / alt / sources / 2607 < prev    next >
Encoding:
Text File  |  1992-11-23  |  2.3 KB  |  69 lines

  1. Newsgroups: alt.sources
  2. Path: sparky!uunet!noc.near.net!lynx!usenet
  3. From: ratinox@splinter.coe.northeastern.edu (Richard Pieri)
  4. Subject: Re: Zap a user
  5. In-Reply-To: Tod McQuillin's message of Mon, 23 Nov 1992 13:10:08 -0500 
  6. Message-ID: <RATINOX.92Nov23155139@splinter.coe.northeastern.edu>
  7. Lines: 52
  8. Sender: usenet@lynx.dac.northeastern.edu (usenet dummy)
  9. X-Posting-Software: GNUS 3.14.1 [ NNTP-based News Reader for GNU Emacs ]
  10. Reply-To: ratinox@meceng.coe.northeastern.edu
  11. X-Signature-Virus-Protection: Version 1.51
  12. X-Get-A-Clue: Have two, they're small.
  13. Organization: 3WA, Boston Office. Or Nu Meta Chi. Take your pick.
  14. References: <gf4Fu0O00WB7EcL1RX@andrew.cmu.edu>
  15. Date: Mon, 23 Nov 1992 20:48:50 GMT
  16.  
  17. >>>>> In article <gf4Fu0O00WB7EcL1RX@andrew.cmu.edu>, Tod McQuillin
  18. >>>>> <tm8t+@andrew.cmu.edu> writes:
  19.  
  20. TM> Recently one of our (ever watchful for ways to improve efficiency)
  21. TM> machine room operators came to me and asked if there was a way to
  22. TM> automate the procedure of knocking users off the system.
  23. TM> Frequently people would call him and say "My terminal is frozen,
  24. TM> can you kill all my proceses?".
  25.  
  26. Education is, of course, the best solution. But sometimes you need to
  27. kill everything a single user is running, or whatever. This script
  28. grew from a small function one of NU's sysmonsters wrote for bash, I
  29. turned it into a nicer shell script, and was further cleaned up by
  30. another NU sysmonster. One nice feature is that it won't try to kill
  31. itself while it's trying to kill something else.
  32.  
  33. -----begin "thwap" script-----
  34. #!/bin/sh
  35. #
  36. # Rat's thwap script, diffed a tiny bit.
  37. #
  38. # Kills all processes with a certain string in them.
  39.  
  40. if [ $# -lt 1 ]; then
  41.   echo "usage: $0 [-signal] user|process [user|process ...]"
  42.   exit 1
  43. fi
  44.  
  45. case $1 in
  46.   -* )
  47.     sig="-1"
  48.     shift
  49.     ;;
  50.   * )
  51.     sig="-9"
  52. esac
  53.  
  54. for proc in $@ ; do
  55.   for pid in `ps auxw | grep -v awk | awk "/$proc/{print \\$2}"`; do
  56.     if [ $pid -ne $$ ]; then
  57.       echo kill $sig $pid
  58.       kill $sig $pid
  59.     fi
  60.   done
  61. done
  62. -----end-----
  63.  
  64. --Rat
  65. ||||| | | | |  |  |  |   |   |    |    |    |   |   |  |  |  |  | | | | | |||||
  66. Northeastern's Stainless Steel Rat          ratinox@meceng.coe.northeastern.edu
  67. It is a proud and lonely thing to be a Stainless Steel Rat.
  68.                                                         --`Slippery' Jim DiGriz
  69.