]> arthur.barton.de Git - netatalk.git/blob - contrib/nu/nu
ecd7a13881baa59cab522c081bcad9f2a56982f8
[netatalk.git] / contrib / nu / nu
1 #! /usr/bin/perl
2
3 # nu - by Anders Brownworth   anders@thehamptons.com
4 #      modified by Ambrose Li <acli@mail.mingpaoxpress.com>
5 #
6 # shows netatalk users logged on
7 #
8 # usage: nu
9
10 open(USERS, "-|") || exec("/bin/ps", "anucx");
11
12 while (<USERS>) {
13    push(@users, $1) if /^\s*(\d+)\s.*\bafpd\b/;
14 }
15
16 close USERS;
17
18 print "Netatalk users:\n---------------\n";
19
20 foreach $user (@users)
21 {
22   if ($user) {  # not root
23     ($name,$_,$_,$_,$_,$_,$gcos) = getpwuid($user);
24     print(defined $gcos && $gcos =~ /^([^,]+)/? $1: $name, "\n");
25   }
26 }