home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!elroy.jpl.nasa.gov!swrinde!zaphod.mps.ohio-state.edu!news.acns.nwu.edu!casbah.acns.nwu.edu!erude
- From: erude@casbah.acns.nwu.edu (Erick Rudiak)
- Newsgroups: comp.unix.questions
- Subject: Re: I want a program that prints out base gid's of any user
- Message-ID: <1992Aug28.142243.15708@news.acns.nwu.edu>
- Date: 28 Aug 92 14:22:43 GMT
- References: <BtIqyp.F5A@news.cso.uiuc.edu> <15360003@hprpcd.rose.hp.com> <1992Aug27.231703.17793@pbhya.PacBell.COM>
- Sender: usenet@news.acns.nwu.edu (Usenet on news.acns)
- Organization: Northwestern University, Evanston, Illinois
- Lines: 34
-
- |> >In comp.unix.questions, bzg52408@uxa.cso.uiuc.edu (Benjamin Z. Goldsteen) writes:
- >| I have been trying to write a program that prints out the
- >| base gid of a user (given on the command line). I have tried
- >| using awk and perl, but I can not get anything decent.
-
- Assuming you give the user name on the command line, such as
-
- % getgroup username
-
- you could do something as easy as:
-
- #! /bin/sh
- #
- # Script to generate group id for user from /etc/password file
-
- GROUPID=`grep $1 /etc/passwd | cut -d: -f4`
- echo "The group id for $1 is: " $GROUPID
-
-
- What this does is look for the user's entry in /etc/passwd. You might
- want to put something in there to look for only that user specifically, because
- their password entry might be a string that is contained in someone *else*'s
- entry as well. Just save the above script as getgroup and you're set.
-
- -- Erick
- _____________________________________________________________________
- |
- I tell myself, hey, only fools rush in | Erick Rudiak
- Only time will tell if we stand the test of time| erude@nwu.edu
- And all I know, you've got to run to win |____________________
- And I'll be damned if I get hung up on the line | "I'm not worthy..."
- | \o/ \o/
- -- Van Halen, "Why Can't This Be Love" | O__ \\ O__ \\
- ________________________________________________|_/__|__||__/__|_||__
-