data scientist, biophysicist, mac-unix zealot, pythonista

Automated Notifications of Experiment Progress: Prowl Extra Credit

Previously, I posted about using Growl in combination with Prowl to get remote notifications of experiment progress on both a Mac and iPhone. Later that day, I started thinking about some improvements to the script after a brief Twitter conversation with Seth Brown.1

The script depends on the remote Mac being always on and reachable from the internet. This is true for my Mac desktop, but it may not be in many other situations, such as when a laptop is involved. In cases such as these, the notification can be sent directly to Prowl from the shell script itself.2

Posting to Prowl requires only one additional piece of information: a Prowl API key. The API key can be generated and accessed from Prowl's website after logging in. The API key is circled in red below. If there are no active keys,3 they can be generated on this page as well.

"Prowl API Key Generation"

Posting to Prowl using an API key is described in the documentation, but it is quite simple and can be accomplished from the command line with curl like this:

curl -s --data \
"apikey=enter_your_api_key_here&application=Command Line&event=Posting to Prowl" \

Prowl's API then returns an xml string containing information about the success or failure of the post attempt:

<?xml version="1.0" encoding="UTF-8"?>
<success code="200" remaining="993" resetdate="1382212452" />

According to Prowl's documentation, 1,000 API calls are allowed per hour from a single IP address. That should be plenty for simple status posts.

I have also created a new version of the associated shell script that will attempt to ping the remote computer before synchronizing data and sending a Growl notification. If the remote computer is not available, the notification will be posted directly to Prowl.

Have fun!

  1. If you are interested in python, data visualization, R, and pretty much every other cool thing on the internet, you should definitely follow him and read his blog

  2. This alternative could be also be used exclusively instead of Growl. However, I prefer receiving notifications on my Mac if I am actively using it. 

  3. I set up my Prowl account so long ago, that I don't recall if the initial API key was active or if I generated it.