Subject: Re: How to determine which Mac s are connected?
From: Ove Ruben R Olsen (ruben@bdc.no)
Date: Sun Mar 26 2000 - 10:33:43 EST
At 09:33 +0200 on 23.03.00, Patrik Schindler wrote:
> Indeed, a little goodie to keep track which users were connected from
>which machines would be nice, but I have no idea to keep track of
>AppleTalk users.
If you only need the IP-/host-address Anders Brownworth little "nu" script
will do
the trick. Found on http://thehamptons.com/anders/netatalk/utils.html. I have
done some enchanements to the script so that it also shows the
IP-/host-address.
I have sumitted the script to Anders so that if he wish he may put the new
version
out on the web.
The script is also pasted into this message. I have just thrown it togehter to
run on RedHat ;-) - tweaking must probably be applied.
\Ruben.
#!/usr/bin/perl
# nu - by Anders Brownworth anders@thehamptons.com
# modified by Ambrose Li <acli@mail.mingpaoxpress.com>
# modified by Ove Ruben R Olsen <ruben@verden.net>
#
# shows netatalk users logged on and their remote address
# this assumes the netstat -p and ps uax of linux usage
#
# usage: nu
open (NS, "/bin/netstat -p 2>&1|");
while (<NS>) {
last if (/^Active UNIX domain/);
($junk, $remote, $morejunk, $pid) = unpack("A44 A23 A13 A10", $_);
if ( ($junk =~ /afpovertcp/) && ($morejunk != /ESTABLISHED/) ) {
($pid) = split(/\//,$pid,2);
$PID{$pid} = $remote;
}
}
close(NS);
print pack("A10 A6 A24 A20 A20", "USER", "SINCE", "FROM", "NAME"), "\n
";
open(USERS, "/bin/ps -uax|") ;
while (<USERS>) {
($uid, $pid, $junk, $since) = unpack("A8 A6 a36 A5", $_);
$pid =~ tr/ //d;
if ($PID{$pid} ne "") {
($name,$office) = split(/,/,(getpwnam($uid))[6], 3);
print pack("A10 A6 A24 A40", $uid, $since, $PID{$pid}, $name,
$office), "\n
";
}
}
This archive was generated by hypermail 2b28 : Wed Jan 17 2001 - 14:30:18 EST