#! /bin/sh set -e ## Parse the command line. case "$#" in 0 | 1) echo >&2 "Usage: $0 COMMAND SLAVE|:SET ..." exit 1 ;; esac command=$1; shift ## Expand slaves into a big list. slaves=$(expand-list /etc/slaves "$@") ## Now do the stuff. for i in $slaves; do { { { echo "starting..." set +e; ssh "$i" "$command" 3>&-; rc=$?; set -e echo "done (rc = $rc)"; } >&3; } 2>&1 | while IFS= read -r line; do printf "!!! %s\n" "$line"; done; } 3>&1 | while IFS= read -r line; do printf "%s: %s\n" "$i" "$line"; done & done wait