1 #!/bin/sh 2 # wait for amd to start up and then execute program 3 # usage: wait4amd <hostname> [<command> [args ...]] 4 # If only hostname is supplied, command defaults to rsh $hostname 5 # 6 # Package: am-utils-6.x 7 # Author: Erez Zadok <ezk (at] cs.columbia.edu> 8 9 #set -x 10 11 if [ "X$1" = "X" ]; then 12 echo "Usage: wait4amd <hostname> [<command> [args ...]]" 13 exit 1 14 else 15 hostname=$1 16 shift 17 fi 18 19 # set path 20 prefix=@prefix@ 21 exec_prefix=@exec_prefix@ 22 PATH=@sbindir@:@bindir@:${PATH} 23 export PATH 24 25 while true 26 do 27 amq -h $hostname > /dev/null 2>&1 28 if [ $? != 0 ] 29 then 30 # failed 31 echo "Amd not up. Sleeping..." 32 sleep 5; 33 else 34 echo "Amd is active on host $hostname!" 35 cmd=$* 36 if [ -z "${cmd}" ] 37 then 38 cmd="rlogin $hostname" 39 fi 40 echo "Running: $cmd" 41 $cmd 42 echo "Sleep 1 second" 43 sleep 1 44 fi 45 done 46