Skip to content

Instantly share code, notes, and snippets.

@thewoolleyman
Created April 16, 2010 19:22
Show Gist options
  • Save thewoolleyman/368828 to your computer and use it in GitHub Desktop.
Save thewoolleyman/368828 to your computer and use it in GitHub Desktop.
run() {
ssh -i $keypair ubuntu@$host $*
}
run_ensuring_success() {
output=$(run $*)
if [[ $? != 0 ]] ; then
echo "AMIBUILDER: Command failed: $*"
terminate_instance
exit 1
fi
$output # <-- How to I make run_ensuring_success() return the command output like run() does?
}
output1=$(run "hostname") # -> domU-12-31-38-06-C0-71
output2=$(run_ensuring_success "hostname") # -bash: domU-12-31-38-06-C0-71: command not found
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment