(Answer) (Category) Products of Aardvarks With Chisels : (Category) Linux : (Category) Handy shell scripts :
everyhost.sh
#!/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 >
[Append to This Answer]
2000-Jun-22 1:57am
Next: (Answer) pppcheck
This document is: http://www.cloudmaster.com/~sauer/projects/index.cgi?file=67
[Search] [Appearance]
This is a Faq-O-Matic 2.719.
This FAQ administered by sauer@cloudmaster.com