#! /bin/bash -f # Thu, 23 Nov 2006 13:43:27 -0500 # An array containing a list of all machines the user has # account on. Password-less SSH access must be set up # between the client machine and these hosts. export MACHINES="host1.domain1 host2.domain1 \ host3.domain1 \ host1.domain2 \ host2.domain2 \ host3.domain2 \ " export j=1 for i in $MACHINES do export CONFIRM=`ping -c 1 $i | grep "packet loss"` export TRANSMT=`echo $CONFIRM | awk -F ' ' '{print $1}'` export RECEIPT=`echo $CONFIRM | awk -F ' ' '{print $4}'` /usr/bin/ssh $i 'who | grep $USER' > /dev/null if [ "$TRANSMT" == "$RECEIPT" ]; then if [ $? = 0 ] then echo "$j. $i :" echo " Logged in" echo else echo "$j. $i :" echo " Not logged in yet" echo fi export j=`expr $j + 1` fi done