IDependOn-Set: 1 IDependOn-Set: 3 IDependOn-Set: 66 IDependOn-Set: 67 IDependOn-Set: 83 LastModifiedSecs: 961657068 Parent: 66 SequenceNumber: 2 Title: everyhost.sh Part: 0 Author-Set: sauer@cloudmaster.com LastModifiedSecs: 961657068 Type: monospaced Lines: 28 #!/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 > EndPart: 0