# poller.sh HOSTS=("server1" "server2") FILE="/tmp/poller" DATA=$1 # Iterate the hosts to issue command for i in ${HOSTS[@]}; do # Tell host to run command echo "Issuing to $i" ssh $i "echo \"$DATA\" > $FILE" 2> /dev/null # Poll until host has completed command RUN=1 while [ $RUN -eq 1 ]; do RESULT=$(ssh $i ls $FILE 2> /dev/null) if [ $RESULT ]; then echo "File detected, waiting" sleep 1 else echo "File removed" echo "Continuing" RUN=0 fi done done # listener.sh FILE="/tmp/poller" while [ 1 ]; do if [ -f $FILE ]; then echo "File detected" FC=$(cat $FILE) echo "File data: $FC" sleep 3 echo "Removing file" rm $FILE fi done