X-Git-Url: https://defaria.com/gitweb/?a=blobdiff_plain;f=clients%2FHP%2Fbin%2Fwhoison;fp=clients%2FHP%2Fbin%2Fwhoison;h=dcf2fce9b22ff120c216ee2394e5354e89483648;hb=a8c84d2892f07a6863b68a11eb0a4a79ffd71fb5;hp=0000000000000000000000000000000000000000;hpb=95384f94f88aceeb5eef2d322210ba4a438b6512;p=clearscm.git diff --git a/clients/HP/bin/whoison b/clients/HP/bin/whoison new file mode 100644 index 0000000..dcf2fce --- /dev/null +++ b/clients/HP/bin/whoison @@ -0,0 +1,72 @@ +#!/bin/ksh +################################################################################ +# +# File: whoison +# RCS: $Header: whoison,v 1.1 97/05/20 19:56:29 defaria Exp $ +# Description: A script to show you who is on the system +# Author: Andrew DeFaria, California Language Labs +# Created: Wed May 14 00:40:02 PDT 1997 +# Modified: +# Language: Korn Shell +# +# (c) Copyright 2001, Andrew@DeFaria.com, all rights reserved +# +################################################################################ +tmpprefix=/tmp/whoison +command="who | cut -f1 -d' ' | sort -u" + +function cleanup { + if [ ! -z $"tmpprefix" ]; then + rm -f ${tmpprefix}* + fi + + exit +} # cleanup + +trap cleanup INT EXIT ERR + +if [ -z "$PAGER" ]; then + pager=more +else + pager="$PAGER" +fi + +function report_whoison { + machine="$1" + + if [ "$machine" = "$(uname -n)" ]; then + eval $command > $tmpprefix.$$ + else + remsh $machine -n "$command" > $tmpprefix.$$ + fi + + integer nbr_of_users=$(wc -l $tmpprefix.$$ | tr -s " " | cut -f1 -d' ') + + if [ $nbr_of_users -eq 1 ]; then + print "$nbr_of_users user on $machine:\n" + else + print "$nbr_of_users users on $machine:\n" + fi + + integer i=1 + + cat $tmpprefix.$$ | while read user; do + print "$i: $user" + let i=i+1 + done + + print + + rm -f $tmpprefix.$$ +} # report_whoison + +if [ $# -eq 0 ]; then + report_whoison "$(uname -n)" | $pager +else + for machine in "$@"; do + report_whoison "$machine" + done | $pager +fi + +who | cut -f1 -d' ' | sort -u > $tmpprefix.$$ +