Wednesday, July 17, 2013

This script takes list if login names as its arguments and displays the number of terminals that each user us logged on to in a LAN Environment

#!/bin/bash
#
#
# File Name    :    page1_14
# Author    :    Suresh Yadagiri
# Date        :        July 27,2010
# Description    :
# This script takes list if login names as its
# arguments and displays the number of terminals
# that each user us logged on to in a LAN
# Environment   
#

function printusageinfo(){
echo -e "\nUsage: $0 login_names_list\n"
}


if [ $# -eq 0 ]
then
    echo "At least one argument expected"
    printusageinfo
    exit
fi


while [ $# != 0 ]
do
noofterminals=`who -a  | cut -d' ' -f1 | grep -w "$1" | wc -l`
echo "user : $1     No.of terminals logged on: $noofterminals"
shift
done

No comments:

Post a Comment