#!/bin/csh # # hey-you-guys - execute the same command on a cluster of machines. # # This is a cheap substitute for the `prsh` script. # The name is from the movie "The Goonies". # Based on a simpler cluster management script I wrote at Vassar. # # Quote: "With great power comes great responsibility" # # This tool expands your powers to multiple machines. Use it wisely. # # Eric Myers - 25 September 2007 # @(#) $Id:$ ####################################################################### # Machines which are off temporarily and should be out of the pool # set OFF="www16.i2u2.org www17.i2u2.org " set OFF="" # General list of machines. Can include those in $OFF # set HOSTS="data0.i2u2.org data1.i2u2.org" set HOSTS="$HOSTS www10.i2u2.org www11.i2u2.org www12.i2u2.org www13.i2u2.org" set HOSTS="$HOSTS www14.i2u2.org www15.i2u2.org www16.i2u2.org www17.i2u2.org" if ( "$*" == "" ) exit set prog=`basename $0` # Assemble command, with escaped spaces set CMD="" set FRC=0 set INDENT="pr -o 2 -t -w 130 " set SSH_TIMEOUT="7" while( "$*" != "" ) set CMD="$CMD $1" shift end set SSH_OPT="" if( $SSH_TIMEOUT != '' && $SSH_TIMEOUT > 0 ) then set SSH_OPT="-o ConnectTimeout=$SSH_TIMEOUT" endif echo echo "${prog}: " echo " ssh $CMD" echo echo "Press ENTER to execute, or ^C to quit now. " set X=$< foreach H ( $HOSTS ) # Don't give command if machine is in $OFF # if( "$OFF" != "" ) then set is_off="N" foreach D ( $OFF ) if ( "$H" == "$D" ) then echo -n "Host: $H " echo "is OFF " set is_off="Y" break endif end [ $is_off = "Y" ] && continue endif # Give the command, get back the status # echo "ssh $H $CMD " ssh $SSH_OPT $H $CMD | ${INDENT} set RC=$? if ( $RC != 0 ) then echo " ! Failed [$RC] " set FRC=$RC endif echo end exit $FRC #EOF#