SOAP? Bah! What's wrong with /bin/sh?

   Print.Print
Email.Email weblog link
Blog this.Blog this
Edd Dumbill

Edd Dumbill
Apr. 18, 2002 06:29 AM
Permalink

Atom feed for this author. RSS 1.0 feed for this author. RSS 2.0 feed for this author.

The frenzy over Google's new SOAP API is just plain silly. Today I was sent details by a proud PR representative (I'll not mention them, but you'll likely hear from them yourselves) of his company's Google-over-email service, using the SOAP interface. What a waste of space for something that can be done in one line of shell script! Here's how...

Grab your local Linux/BSD box of preference, put this bit of script into a file, say /usr/local/bin/google.sh, and make it executable.

#!/bin/sh
/bin/cat >/tmp/msg$$ && (/usr/bin/formail -b -t -I 'Content-Type: text/html; charset=ISO-8859-1' -r </tmp/msg$$ && QUERY=`/bin/grep Subject /tmp/msg$$ | /bin/sed -e 's/Subject: *//;'` && /bin/rm /tmp/msg$$ && /usr/bin/lynx -source "http://www.google.com/search?num=100&q=$QUERY") | /usr/sbin/sendmail -t -F 'Google mail server' -f google@example.com

Then, edit your /etc/aliases file, and add in something like:

google: "|/usr/local/bin/google.sh"

Run newaliases and you're all set. Send email to the google user on your host, and put your query string in the subject field. You'll get back a nice HTML email with up to 100 results from Google.

It's more or less a one-liner. (You'll need lynx and formail, which comes with procmail, installed.)

Please don't come running to me with SOAP demos until they do something useful.

Edd Dumbill is co-chair of the O'Reilly Open Source Convention. He is also chair of the XTech web technology conference. Edd conceived and developed Expectnation, a hosted service for organizing and producing conferences. Edd has also been Managing Editor for XML.com, a Debian developer, and GNOME contributor. He writes a blog called Behind the Times.