home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / unix / question / 10469 < prev    next >
Encoding:
Internet Message Format  |  1992-08-29  |  2.0 KB

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