Skip to content

Instantly share code, notes, and snippets.

@jazzychad

jazzychad/watchping.sh

Last active Oct 19, 2015
Embed
What would you like to do?
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
You can’t perform that action at this time.