From cafcd5d4368e57f162a641ed3f4835ecb5a6d391 Mon Sep 17 00:00:00 2001 From: Jonas Smedegaard Date: Thu, 28 Feb 2002 14:09:04 +0000 Subject: Initial revision --- macusers | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100755 macusers (limited to 'macusers') 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() + { + 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() +{ + 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); -- cgit v1.2.3