blob: 52d3a53f81a41f73890638b36d112ca0695c7dfe (
plain)
- #!/usr/bin/perl -wT
- #
- # /usr/local/bin/localuserinfo
- # Copyright 2003-2007 Jonas Smedegaard <dr@jones.dk>
- #
- # $Id: localuserinfo,v 1.2 2007-02-07 10:23:08 jonas Exp $
- #
- # Print real name and/or other info for user
- #
- # TODO: Options to print other info than realname
- #
- use strict;
- use User::pwent;
- use User::grent;
- sub getuserinfo($) {
- my $username = shift;
- my $pw = getpwnam($username) || die "Username \"$username\" does not exist.";
- my ($fullname, $office, $workphone, $homephone, $other) = split /\s*,\s*/, $pw->gecos;
- my @addresshints;
- if (defined($other)) {
- @addresshints = grep {/^([\.[:alnum:]_-]+|\+)?@([\.[:alnum:]_-]+)?$/} split /\s+/, $other;
- }
- return ($fullname, @addresshints);
- }
- while (my $username = shift @ARGV) {
- my ($fullname, @addresses) = getuserinfo($username);
- my $localaddress = "$username\@users.kaospilot.no";
- print "$fullname\n";
- }
|