2 ################################################################################
5 # RCS: $Header: whoison,v 1.1 97/05/20 19:56:29 defaria Exp $
6 # Description: A script to show you who is on the system
7 # Author: Andrew DeFaria, California Language Labs
8 # Created: Wed May 14 00:40:02 PDT 1997
10 # Language: Korn Shell
12 # (c) Copyright 2001, Andrew@DeFaria.com, all rights reserved
14 ################################################################################
15 tmpprefix=/tmp/whoison
16 command="who | cut -f1 -d' ' | sort -u"
19 if [ ! -z $"tmpprefix" ]; then
26 trap cleanup INT EXIT ERR
28 if [ -z "$PAGER" ]; then
34 function report_whoison {
37 if [ "$machine" = "$(uname -n)" ]; then
38 eval $command > $tmpprefix.$$
40 remsh $machine -n "$command" > $tmpprefix.$$
43 integer nbr_of_users=$(wc -l $tmpprefix.$$ | tr -s " " | cut -f1 -d' ')
45 if [ $nbr_of_users -eq 1 ]; then
46 print "$nbr_of_users user on $machine:\n"
48 print "$nbr_of_users users on $machine:\n"
53 cat $tmpprefix.$$ | while read user; do
64 report_whoison "$(uname -n)" | $pager
66 for machine in "$@"; do
67 report_whoison "$machine"
71 who | cut -f1 -d' ' | sort -u > $tmpprefix.$$