Skip to content

Instantly share code, notes, and snippets.

@jgoodall
Created July 18, 2012 14:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jgoodall/3136573 to your computer and use it in GitHub Desktop.
Save jgoodall/3136573 to your computer and use it in GitHub Desktop.
send message to notifo service from shell
#!/bin/bash
# Send messages to [notifo](http://notifo.com/)
# the message is passed from the command line
if [ $# -lt 1 ]; then
echo "Usage: " $0 "'the message to send'"
exit 1
else
message=$1
fi
# make sure curl is installed
if [ ! -x `which curl` ]; then
echo "Curl must be installed."
exit 1
fi
# make sure curl >= 7.18 is installed (using --data-urlencode)
CURL_VERSION=`curl --version | head -n 1 | cut -d' ' -f2`
if [ `echo $CURL_VERSION | cut -d'.' -f1` -eq 7 ] && [ `echo $CURL_VERSION | cut -d'.' -f2` -lt 18 ]; then
echo "Curl must be at 7.18 or newer"
exit 1
fi
# users to send the notification to - users must be subscribed
# only seem to be able to send one at a time...
USERS='user1 user2'
# the service registered with notifo and its key
# set up a new service here: http://notifo.com/user/my_services
SERVICE=custom_service_name
APIKEY=custom_service_api_key
# the [notification API](https://api.notifo.com/docs/notifications)
URL=https://api.notifo.com/v1/send_notification
# send the command using curl
for i in $USERS; do
curl -k -u $SERVICE:$APIKEY --data-urlencode "to=$i" --data-urlencode "msg=$message" $URL
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment