home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!noc.near.net!bigboote.WPI.EDU!bigboote.wpi.edu!john
- From: john@sekrit.WPI.EDU (John Stoffel)
- Newsgroups: comp.lang.perl
- Subject: Re: Need tidbit of code to look up user's full name
- Date: 19 Nov 92 08:39:07
- Organization: Worcester Polytechnic Institute
- Lines: 25
- Distribution: usa
- Message-ID: <JOHN.92Nov19083907@sekrit.WPI.EDU>
- References: <1992Nov19.025121.4550@cis.ohio-state.edu>
- NNTP-Posting-Host: sekrit.wpi.edu
- In-reply-to: fontana@iguana.cis.ohio-state.edu's message of 19 Nov 92 02:51:21 GMT
-
- >>>>> On 19 Nov 92 02:51:21 GMT, fontana@iguana.cis.ohio-state.edu (Mark Fontana) said:
- Mark> Article-I.D.: cis.1992Nov19.025121.4550
-
-
- Mark> Hi,
-
- Mark> I'm just beginning to learn perl, and I would like to have a program
- Mark> determine the first name of the user invoking it. Presently, it
- Mark> gets the user's login name through environment variable USER. I
- Mark> would like the program to determine the user's full name (by checking
- Mark> the gecos(?) field). I'd appreciate it if someone could give an
- Mark> example of how to do this.
-
- #!/usr/local/bin/perl
-
- @user = getpwuid($<);
- @name = split(/ /,$user[6],2);
- print "$name[0]\n";
-
-
- --
- Youth of today! Join me in a mass rally for traditional mental attitudes!
- -------------------------------------------------------------------------------
- john@wpi.wpi.edu | Work Station Specialist | Worcester Polytechnic Institute
- John Stoffel | 508-831-5512 (work) | Worcester, MA 01609
-