multiple machines

Matt Ranney mjr at unction.calvin.edu
Thu Jun 20 12:26:10 AEST 1991


In our CAD lab we have several Sparc IPC's mounting /home from a
server.  In my shell, I like to keep a .trashcan type thing that all
my "rm'ed" files get moved into.  When I log out, I want to blow all
this stuff away.  The way I figured out how to do it works, but it
seems kinda awkward to me.  Is there a more efficient/"better" way I
could do this?  (My shell is GNU bash, basically sh syntax)


us=`hostname`
hosts='uther ulan unction'     # the three machines we presently have
for me in `echo $hosts | sed "s/${us}//"`
do
echo -n "Checking "
echo $me
	if rusers $me | grep $LOGNAME >& /dev/null
	then
		echo "Still logged in on ${me}.  Not removing trash."
		kill -9 $$
	fi
done

if [ `who | grep ${LOGNAME} | wc -l` -eq 1 ]
then
	echo -n "Emptying the trash..."
	/bin/rm -rf ~/tmp
	echo "done"
	echo
	/usr/games/fortune 
	echo "Outta here.............."
else
	echo "Still logged in on this machine, not removing trash"
fi


Any suggestions/comments would be appreciated.  I'm just starting to
learn shell programming, so this is probably really inefficient and
slow.



--
Matt Ranney
mjr at uther.calvin.edu



More information about the Comp.unix.shell mailing list