#!/bin/bash
################################################################################
# everywhere.sh
# execute a command on all teh machines in the lab
# one argument must be provided, which is the path to the program to run
# normally I write a small shell script to do what I want, put it in my
# NFS-mounted-everywhere home directory, and use that script as the command
# to run
# you need a list of hosts, one per line, in the file cpointed to by ALLHOSTS
################################################################################
ALLHOSTS=`cat ~sauer/allhosts`
if [ ! $1 ]; then
echo "Aaargh! You need to tell me what to do..."
else
stty -echo # don't echo the root password
read -ep "Root Password: "
stty echo # start echoing again so the termian doesn't get screwy
echo
for BOX in $ALLHOSTS; do
if ping -c1 -w1 $BOX | tail -n1 | grep '100% packet loss'; then
echo "$BOX is down."
else
echo -n "$BOX: "
echo $REPLY | rsh $BOX su -c \'echo\;$1\'
fi
done
fi
sauer@csc:/export/staff/sauer > |