Skip to content

Instantly share code, notes, and snippets.

@gerhard
Created June 5, 2012 00:32
Show Gist options
  • Save gerhard/2871690 to your computer and use it in GitHub Desktop.
Save gerhard/2871690 to your computer and use it in GitHub Desktop.
bash ssh exit status
Calista ➜ deliver git:(multi-server) ✗ multi
/usr/local/bin/parallel
FAILED!
#!/usr/bin/env bash
check_if_failed() {
local _status="$1"
if [ ! "$_status" = 0 ]
then
echo "FAILED!"
exit 1
fi
}
pids=()
for host in $hosts
do
ssh -o ConnectTimeout=2 $host "
set -e
which parallel
sleep 1
" &
pids+=("$!")
done
for pid in "${pids[@]}"
do
wait "$pid"
check_if_failed "$?"
done
echo "All is good!"
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment