Skip to content

Instantly share code, notes, and snippets.

@chromy
Created November 16, 2013 17:45
Show Gist options
  • Save chromy/7503132 to your computer and use it in GitHub Desktop.
Save chromy/7503132 to your computer and use it in GitHub Desktop.
#!/bin/bash
APPLICATION_TOKEN=a3MxpesaEnciPeqqsYBrzZatpwrDQ9
USER_TOKEN=$PUSHOVER_USER_TOKEN
URL=https://api.pushover.net/1/messages.json
function push_alert() {
curl -s \
-F "token=$APPLICATION_TOKEN" \
-F "user=$USER_TOKEN" \
-F "message=$1" \
$URL
}
function main() {
if [[ $# -eq 0 ]] ; then
echo "Usage: $0 [command]"
exit 0
fi
# Run command in sub shell.
(${@:1})
code=$?
if [ $code -ne 0 ]; then
push_alert "Command ${@:1} failed with status $code."
fi
}
main $@
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment