Skip to content

Instantly share code, notes, and snippets.

@PhirePhly
Created March 21, 2012 16:28
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save PhirePhly/2149305 to your computer and use it in GitHub Desktop.
Save PhirePhly/2149305 to your computer and use it in GitHub Desktop.
A simple shell wrapper to make posting to prowl easier from anything.
#!/bin/sh
# Kenneth Finnegan, 2012
# kennethfinnegan.blogspot.com
# Posts growl notifications to iOS device using prowl & curl
#
# Pass this script two (or three) arguments with the message title,
# (the message priority,) and the message.
#
# Dumps the XML response from prowl to LOG, which can be ignored
# unless you're coming anywhere close to the 1000/hr rate.
# 2012 03 08: Initial fork from morningreport.sh
# 2012 03 21: Replaced the hardcoded application name with `hostname`
APIKEY=25XXXX77
LOG="/tmp/prowl.log"
touch $LOG
chmod -f 666 $LOG
# Based on if we have two or three arguments, change the default priority
if [ $# -eq "2" ]; then
EVENT_NAME=$1
PRIORITY="0"
EVENT_DESC=$2
elif [ $# -eq "3" ]; then
EVENT_NAME=$1
PRIORITY=$2
EVENT_DESC=$3
else
echo "USAGE: $0 \"Event name\" \"[priority]\" \"Message body\" " \
>/dev/fd/2
exit
fi
# Post notification to Prowl using curl
curl -s https://api.prowlapp.com/publicapi/add \
-F apikey="$APIKEY" \
-F priority="$PRIORITY" \
-F application="`hostname`" \
-F event="$EVENT_NAME" \
-F description="$EVENT_DESC" > /tmp/prowl.log
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment