summaryrefslogtreecommitdiff
path: root/macusers
diff options
context:
space:
mode:
authorJonas Smedegaard <dr@jones.dk>2002-02-28 14:09:04 +0000
committerJonas Smedegaard <dr@jones.dk>2002-02-28 14:09:04 +0000
commitcafcd5d4368e57f162a641ed3f4835ecb5a6d391 (patch)
tree56166fbf16289d8b388cf0f1f9b51e28c3c4bdf9 /macusers
Initial revision
Diffstat (limited to 'macusers')
-rwxr-xr-xmacusers52
1 files changed, 52 insertions, 0 deletions
diff --git a/macusers b/macusers
new file mode 100755
index 0000000..ac930d2
--- /dev/null
+++ b/macusers
@@ -0,0 +1,52 @@
+#!/usr/bin/perl
+
+# Written for linux; may have to be modified for your brand of Unix.
+
+$MAC_PROCESS="afpd";
+$PS_STR="-ef";
+$ASIP_PORT="afpovertcp";
+
+# Change to 0 if you don't have lsof
+$LSOF=1;
+
+if ($LSOF == 1 )
+{
+ open(LSOF,"lsof -i | grep $ASIP_PORT |");
+
+ while(<LSOF>)
+ {
+ if ($_ !~ /$ASIP_PORT/)
+ {
+ next;
+ }
+ $_=~/\w+\s+(\d+).*->([\w-]+).*/;
+ $pid=$1; $host=$2;
+ $mac{$pid}=$host;
+ }
+
+ close(LSOF);
+ print "PID UID Usercode Name Logintime Mac\n";
+}
+else
+{
+ print "PID UID Usercode Name Logintime\n";
+}
+
+open(PS," ps $PS_STR |") || die "cannot do ps";
+
+while(<PS>)
+{
+ if ($_ !~ /$MAC_PROCESS/ )
+ {
+ next;
+ }
+ $_=~ /\s*(\w+)\s+(\d+)\s+(\d+)\s+\d+\s+([\d\w:]+)/;
+ $user=$1; $pid=$2; $ppid=$3; $time=$4;
+ if ($ppid != 1)
+ {
+ ($t,$t,$uid,$t,$t,$t,$name,$t,$t)=getpwnam($user);
+ printf "%-8d %-8d %-8s %-20s %-9s %s\n",$pid,$uid,$user,$name,$time,$mac{$pid};
+ }
+}
+
+close(PS);