]> arthur.barton.de Git - netatalk.git/blob - contrib/nu/nu.in
Auto-generate Perl scripts so the the path to the interpreter will be
[netatalk.git] / contrib / nu / nu.in
1 #!@PERL@
2 #
3 # $Id: nu.in,v 1.1 2002-01-17 05:59:25 srittau Exp $
4 #
5 # nu - by Anders Brownworth   anders@thehamptons.com
6 #      modified by Ambrose Li <acli@mail.mingpaoxpress.com>
7 #
8 # shows netatalk users logged on
9 #
10 # usage: nu
11
12 open(USERS, "-|") || exec("/bin/ps", "anucx");
13
14 while (<USERS>) {
15    push(@users, $1) if /^\s*(\d+)\s.*\bafpd\b/;
16 }
17
18 close USERS;
19
20 print "Netatalk users:\n---------------\n";
21
22 foreach $user (@users)
23 {
24   if ($user) {  # not root
25     ($name,$_,$_,$_,$_,$_,$gcos) = getpwuid($user);
26     print(defined $gcos && $gcos =~ /^([^,]+)/? $1: $name, "\n");
27   }
28 }