Abusing the command line
If you’re running OS X, try this:
say -v Kathy `curl --silent http://api.technorati.com/getinfo?username=simonwillison | grep ’<inbound’ | sed -e ’s/ <//’ | sed -e ’s/inboundblogs>/Simons blog has /’ | sed -e ’s/<\/inboundblogs>/ inbound blogs and /’ | sed -e ’s/inboundlinks>//’ | sed -e ’s/<\/inboundlinks>/ inbound links/’`
Your computer should read out to you my Technorati inbound blogs and inbound links, extracted from the Technorati web API. Parsing XML using sed is a nasty trick I picked up from this O’Reilly article; speaking the output of a command using the ’say’ and the backtick shell operator was my moment of inspiration for the day.
Gina - 26th March 2004 02:56 - #
Michael - 26th March 2004 04:09 - #
or, on a linux system:
Your comment could not be added:
* XHTML is not well-formedoh well, i tried.
Eric - 26th March 2004 05:41 - #
Simon Willison - 26th March 2004 06:46 - #
You don't need all those sed commands. You can join them up into one big sed command with lots of -e flags. It'll run ever so slightly quicker. :-)
Whilst it's a very cute one liner, I'm finding more and more that I would knock up a quick XSLT stylesheet to do jobs like this instead. It's a lot less brittle if you end up using it a lot. I would say that XSLT is hard, but compared to Unix shell scripting, there's probably not much in it! It doesn't have the "one liner" factor as much though.
-Dom
Dominic Mitchell - 26th March 2004 07:16 - #
Ok, I couldn't resist. Here's a slightly condensed version.
say -v Kathy `curl --silent "http://api.technorati.com/getinfo?username=simonw illison" | sed '/<inbound/{s/ <//; s/inboundblogs>/Simons blog has /; s/<\/inboundblogs>/ inbound blogs and /; s/inboundlinks>//; s/<\/inboundlinks>/ inbound links/;}'`Dominic Mitchll - 26th March 2004 07:23 - #
On Debian you can also use flite:
echo 'hello' | fliteLevin - 26th March 2004 11:48 - #