home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / unix / wizards / 3342 < prev    next >
Encoding:
Text File  |  1992-07-28  |  2.4 KB  |  70 lines

  1. Newsgroups: comp.unix.wizards
  2. Path: sparky!uunet!cis.ohio-state.edu!pacific.mps.ohio-state.edu!linac!uwm.edu!psuvax1!atlantis.psu.edu!darwin.psu.edu!barr
  3. From: barr@darwin.psu.edu (David Barr)
  4. Subject: Re: Making ``.plan'' EXECUTE a Program ???
  5. Message-ID: <#q61Hejis8@atlantis.psu.edu>
  6. Sender: news@atlantis.psu.edu (Usenet)
  7. Organization: Population Research Institute
  8. References: <31567@adm.brl.mil>
  9. Date: Wed, 29 Jul 92 14:04:53 GMT
  10. Lines: 58
  11.  
  12. In article <31567@adm.brl.mil> Perry_Hutchison.Portland@xerox.com writes:
  13. >#!    /bin/csh
  14.  
  15. <shudder>
  16.  
  17. >egrep -v '^\+::0:0:::$|uucico$' /etc/passwd > /tmp/userlist
  18. >chmod 644 /tmp/userlist
  19. >if ( { egrep -s '^\+::0:0:::$' /etc/passwd } ) then
  20. >  # Try to get more names from NIS
  21. >  # status of 0 from ypwhich means yp service is available on this network
  22. >  if ( { ( ypwhich >>& /dev/null ) } ) then
  23. >    ypcat passwd | egrep -v '^\+::0:0:::$|uucico$' >> /tmp/userlist
  24. >  endif
  25. >endif
  26. >#
  27. >ex /tmp/userlist <<E\OF
  28. >g/^[^:][^:]*:[^:]:/d
  29. >g/^[^:][^:]*:[^:][^:]:/d
  30. >g/^[^:][^:]*:[^:][^:][^:]:/d
  31. >g/^[^:][^:]*:[^:][^:][^:][^:]:/d
  32. >g/^[^:][^:]*:[^:][^:][^:][^:][^:]:/d
  33. >g/^[^:][^:]*:[^:][^:][^:][^:][^:][^:]:/d
  34. >g/^[^:][^:]*:[^:][^:][^:][^:][^:][^:][^:]:/d
  35. >g/^[^:][^:]*:[^:][^:][^:][^:][^:][^:][^:][^:]:/d
  36. >g/^[^:][^:]*:[^:][^:][^:][^:][^:][^:][^:][^:][^:]:/d
  37. >g/^[^:][^:]*:[^:][^:][^:][^:][^:][^:][^:][^:][^:][^:]:/d
  38. >g/^[^:][^:]*:[^:][^:][^:][^:][^:][^:][^:][^:][^:][^:][^:]:/d
  39. >g/^[^:][^:]*:[^:][^:][^:][^:][^:][^:][^:][^:][^:][^:][^:][^:]:/d
  40. >g/^[^:][^:]*:[^:][^:][^:][^:][^:][^:][^:][^:][^:][^:][^:][^:][^:][^:][^:]*:/d
  41. >g/^[^:][^:]*:[^:]*:[^:]:/d
  42. >g/:.*$/s///
  43. >x
  44. >E\OF
  45.  
  46. awk is your friend.
  47.  
  48. foreach user (`/usr/bin/ypcat passwd | /usr/bin/egrep -v '^\+|ftp|demo' | awk -F: '{ print $1 }'`)
  49.     #execute user boot script
  50. end
  51.  
  52.  
  53. no temp files, and it's got to be a heck of a lot faster than using ex
  54. and files.  It doesn't look at users in /etc/passwd, but there shouldn't be
  55. much of anyone of interest in there anyway.  (Stuff like root, nobody, and
  56. daemon?)  If you're not running NIS, then well you can change it to use
  57. nidump or /etc/passwd.  
  58.  
  59. If you really need to use two sources for your user list, then use
  60. something like
  61.  
  62. set userlist=`/usr/bin/egrep -v '^\+|uucp|news|sync|' | awk ....`
  63. set userlist="$userlist `/usr/bin/ypcat passwd | egrep ....`"
  64. foreach user ($userlist)
  65.  
  66. --Dave
  67. -- 
  68. System Administrator, Population Research Institute    barr@darwin.psu.edu
  69. Emacs is a fine operating system, but I still prefer UNIX. - Tom Christiansen
  70.