Last active
October 19, 2015 21:00
-
-
Save jazzychad/bb51378052b38475c71a to your computer and use it in GitHub Desktop.
watchping
This file contains 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
#!/bin/bash | |
# add to .bash_profile or whatever | |
# usage: add after another command by using a semi-colon | |
# e.g. sleep 40; watchping i just slept | |
# do not use && or ||, it is unnecessary, it will check the exit value of | |
# previous command to determine whether to send SUCCESS or FAILED message | |
# define as a function so that it runs in the same shell context (important!) | |
watchping() | |
{ | |
RESULT=$? | |
DESC=`echo $@ | sed "s/ /%20/g"` | |
if [ $RESULT -eq 0 ] | |
then | |
# you can use whatever push notification service you prefer, this is for prowl | |
curl -s -d "apikey=xxxxxxxxx&application=cmd&event=SUCCESS&description=$DESC" https://api.prowlapp.com/publicapi/add | |
else | |
curl -s -d "apikey=xxxxxxxxx&application=cmd&event=FAILED&description=$DESC" https://api.prowlapp.com/publicapi/add | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment