Skip to content

Instantly share code, notes, and snippets.

@jazzychad
Last active October 19, 2015 21:00
Show Gist options
  • Save jazzychad/bb51378052b38475c71a to your computer and use it in GitHub Desktop.
Save jazzychad/bb51378052b38475c71a to your computer and use it in GitHub Desktop.
watchping
#!/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