#! /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 | sed 's/^/!!! /'; } 3>&1 | sed "s^$i: " & done wait