home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.unix.wizards
- Path: sparky!uunet!cis.ohio-state.edu!pacific.mps.ohio-state.edu!linac!uwm.edu!psuvax1!atlantis.psu.edu!darwin.psu.edu!barr
- From: barr@darwin.psu.edu (David Barr)
- Subject: Re: Making ``.plan'' EXECUTE a Program ???
- Message-ID: <#q61Hejis8@atlantis.psu.edu>
- Sender: news@atlantis.psu.edu (Usenet)
- Organization: Population Research Institute
- References: <31567@adm.brl.mil>
- Date: Wed, 29 Jul 92 14:04:53 GMT
- Lines: 58
-
- In article <31567@adm.brl.mil> Perry_Hutchison.Portland@xerox.com writes:
- >#! /bin/csh
-
- <shudder>
-
- >egrep -v '^\+::0:0:::$|uucico$' /etc/passwd > /tmp/userlist
- >chmod 644 /tmp/userlist
- >if ( { egrep -s '^\+::0:0:::$' /etc/passwd } ) then
- > # Try to get more names from NIS
- > # status of 0 from ypwhich means yp service is available on this network
- > if ( { ( ypwhich >>& /dev/null ) } ) then
- > ypcat passwd | egrep -v '^\+::0:0:::$|uucico$' >> /tmp/userlist
- > endif
- >endif
- >#
- >ex /tmp/userlist <<E\OF
- >g/^[^:][^:]*:[^:]:/d
- >g/^[^:][^:]*:[^:][^:]:/d
- >g/^[^:][^:]*:[^:][^:][^:]:/d
- >g/^[^:][^:]*:[^:][^:][^:][^:]:/d
- >g/^[^:][^:]*:[^:][^:][^:][^:][^:]:/d
- >g/^[^:][^:]*:[^:][^:][^:][^:][^:][^:]:/d
- >g/^[^:][^:]*:[^:][^:][^:][^:][^:][^:][^:]:/d
- >g/^[^:][^:]*:[^:][^:][^:][^:][^:][^:][^:][^:]:/d
- >g/^[^:][^:]*:[^:][^:][^:][^:][^:][^:][^:][^:][^:]:/d
- >g/^[^:][^:]*:[^:][^:][^:][^:][^:][^:][^:][^:][^:][^:]:/d
- >g/^[^:][^:]*:[^:][^:][^:][^:][^:][^:][^:][^:][^:][^:][^:]:/d
- >g/^[^:][^:]*:[^:][^:][^:][^:][^:][^:][^:][^:][^:][^:][^:][^:]:/d
- >g/^[^:][^:]*:[^:][^:][^:][^:][^:][^:][^:][^:][^:][^:][^:][^:][^:][^:][^:]*:/d
- >g/^[^:][^:]*:[^:]*:[^:]:/d
- >g/:.*$/s///
- >x
- >E\OF
-
- awk is your friend.
-
- foreach user (`/usr/bin/ypcat passwd | /usr/bin/egrep -v '^\+|ftp|demo' | awk -F: '{ print $1 }'`)
- #execute user boot script
- end
-
-
- no temp files, and it's got to be a heck of a lot faster than using ex
- and files. It doesn't look at users in /etc/passwd, but there shouldn't be
- much of anyone of interest in there anyway. (Stuff like root, nobody, and
- daemon?) If you're not running NIS, then well you can change it to use
- nidump or /etc/passwd.
-
- If you really need to use two sources for your user list, then use
- something like
-
- set userlist=`/usr/bin/egrep -v '^\+|uucp|news|sync|' | awk ....`
- set userlist="$userlist `/usr/bin/ypcat passwd | egrep ....`"
- foreach user ($userlist)
-
- --Dave
- --
- System Administrator, Population Research Institute barr@darwin.psu.edu
- Emacs is a fine operating system, but I still prefer UNIX. - Tom Christiansen
-