2 ################################################################################
5 # Description: Runs an arbitrary command on all machines
6 # Author: Andrew@DeFaria.com
7 # Created: Fri Apr 30 14:17:40 PDT 1999
9 # Modifications:Added trapping of INT so that you can abort a non-responding
12 # (c) Copyright 2001, Andrew@DeFaria.com, all rights reserved
14 ################################################################################
15 # Set me to command name
19 adm_base=${adm_base:-$HOME/adm}
22 adm_fpath=${adm_fpath:-$adm_base/functions}
28 machines=${machines:-$adm_base/data/machines}
30 if [ "$1" = "-f" ]; then
36 if [ "$1" = "-r" ]; then
41 if [ ! -f $machines ]; then
42 error "Unable to find $machines file!" 1
46 display "${machines[i]}:$cmd interrupted"
47 display "(A)bort $me or (C)ontinue with next machine? \c"
49 typeset -l response=$response
53 display "Aborting $me..."
57 display "Continuing on with the next machine..."
60 # Build up data arrays. Note this is done because if we remsh while in a pipe
61 # Sun will not allow a simple remsh with no command (boo!)
62 # Column 1 Machine name
65 # Column 4 ClearCase Version (if applicable)
66 # Column 5 Owner (if known)
67 # Column 6 Usage (if known)
70 integer nbr_of_machines=0
71 sed -e "/^#/d" $machines |
72 while read machine model osversion ccversion owner phone usage location;
74 machines[nbr_of_machines]=$machine
75 models[nbr_of_machines]=$model
76 #osversions[nbr_of_machines]=$osversion
77 #ccversions[nbr_of_machines]=$ccversion
78 #owners[nbr_of_machines]=$owner
79 #phones[nbr_of_machines]=$phone
80 #usages[nbr_of_machines]=$usage
81 #locations[nbr_of_machines]=$location
82 let nbr_of_machines=nbr_of_machines+1
86 # This loop executes the command
89 while [ $i -lt $nbr_of_machines ]; do
90 export currmachine=${machines[i]}
91 # Execute command. Note if no command is given then the effect is to
92 # rlogin to each machine.
93 print -u2 "${machines[i]}\c"
97 if [ "$root_remsh" = "true" ]; then
98 remsh ${machines[i]} -n -l root "$cmd"
100 remsh ${machines[i]} -n "$cmd"
103 if [ "$root_remsh" = "true" ]; then
104 remsh ${machines[i]} -l root