Continuing adventures in command lines

I have a confession to make. As much as I like customizing the graphics and functionality of my desktop, I mostly like typing commands and not using my mouse. But using the keyboard and obscure commands goes much further than navigating my desktop. These days, I can send commands to services all over the internet via Twitter, something I’ll write more about when I have more time (but for an idea of what I’m talking about, check this out and notice the footnote about Twitter).

In particular, I use Ping.fm to send status updates and the like to most of the services I use. Instead of going around to my Twitter, identi.ca, Facebook, LinkedIn and other accounts, I can make one visit to Ping.fm and update them all, or whichever ones I choose.

On my desktop, I use Launchy, an extremely useful, extensible launch bar that indexes my files, programs and folders for quick launching with a few keystrokes. This evening, I worked out how to send messages to Ping.fm from Launchy. It took some tweaking, but the result is that no matter what I’m doing I can very quickly send and post a message to any combination of online services I want.

Here’s how it worked: Ping.fm doesn’t seem to have an http API, which would be the most straightforward way to do this and would make use of cURL, which I already use to post messages straight to Twitter. But Ping.fm does provide a unique email address to every user, and any message going to that email address is treated as a Ping.fm command.

To send an email to Ping.fm from the command line, I set up Blat. Blat is a public domain utility that sends over SMTP from the command line. One problem stood in my way: Since I use a laptop and often use different networks, I need one SMTP server to use all the time to avoid frequent changes to my email settings. For a long time now I’ve been using Google’s Gmail SMTP service which not only lets me send mail from anywhere on the internet but also indexes the email I send in my gmail account as though I had used the web interface to send it.

The difficulty with Google’s servers is that they use encrypted connections, and Blat doesn’t support encryption. Not to worry though, because sTunnel provides the missing link. sTunnel can be set up to listen to a particular local port and send it encrypted to a remote port. I set it up as a Windows service listening on Localhost:259 and forwarding anything on that port to smtp.gmail.com:465. Here is my stunnel.conf file:

client = yes

[ssmtp]
accept  = 259
connect = smtp.gmail.com:465

That’s it. With sTunnel running under that configuration, I have Blat send commands as emails addressed to Ping.fm, but destined for one of my accounts in the cloud. To install Blat, I ran:

Blat -install 127.0.0.1 myaddress@mydomain.com 1 259 – username password

I suggest copy-and-pasting that command if you’re using this as a guide: That dash before the username has a space after it. If you set this up, you’ll obviously change that to your own email address, username and password. I use Google Apps with my own domain name so the username is actually my whole email address. It works just fine.

Summing up then, I pop open Launchy and type a command that goes from Launchy to Blat through sTunnel to GMail to Ping.fm and finally to one of the many services I use that Ping.fm can connect to. Sound complicated? Maybe it is, but it will make things fast and easy for me.

Next up: Improved sending from the command line to Twitter, which can then send to calendars and todo lists. Maybe there will even be a command line way to create Google Tasks before too long! (And speaking of that, is it just me or is it surprising that Google decided to make Tasks a part of GMail instead of part of Google Calendar? Aren’t Tasks inherently more like events or appointments than they are like communications? Or is Google taking a page from the Chandler Project and orienting everything around communications?)

Tagged , ,
%d bloggers like this: