iPhone and Linux

Sunday, October 25, 2009

Send MobileTerminal output to Prowl

One of the downsides to MobileTerminal is that it doesn't support copy and paste. You can direct the output to a file and open it later to copy the contents if needed, but I worked out a solution that I like better; pipe the output to Prowl.

The output is sent over the internet to the Prowl notification service which then sends it to your phone in the form of a push notification. It's a strange way of getting the output, but it's sure handy.

All you need to do is get the output into a variable, then use curl to post it to the Prowl API. The best way to do capture the input from a pipe is with "< /dev/stdin", which works on my computer but does not work on the phone, so I had to use "cat -"

I named the script "i", so whenever I want to use it, I just add "| i" on the command line and the output goes to Prowl, e.g: echo "Hello World" | i

#! /bin/sh
out=$(cat -)
curl -k https://prowl.weks.net/publicapi/add -d apikey=XXXXX -d application="pipe" -d description="$out"

Blog Archive