Created
June 5, 2012 00:32
-
-
Save gerhard/2871690 to your computer and use it in GitHub Desktop.
bash ssh exit status
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Calista ➜ deliver git:(multi-server) ✗ multi | |
/usr/local/bin/parallel | |
FAILED! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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