Posts categorized “cmdline_tweet”.

Simple tweeting from the command line

A while back, we needed a way to monitor the status of some long-running batch processes, in this case some environmental simulations we wanted to run over the weekend while we were away. We can access the machines via remote desktop, but that isn’t always timely or convenient, so I came up with a simple Python program which our batch scripts called to update the run status via Twitter: cmdline_tweet.

From a dedicated Twitter account, we could check on things from our smartphones (or however we like) and know immediately if some error had occurred. Since these runs can take 8 hours or more to complete (and, as always, we’re working with deadlines), there’s a big difference between knowing “now” and knowing “whenever I get around to checking.”

The client has a one-time authentication stage where it gets associated with your account via OAuth, and after that tweeting is as simple as:

~$ tweet "Hello, world!"

The source includes a Makefile which helps compile into a binary for dead-simple deployment on machines without Python installed. And copying or renaming the file will let you connect with more than one Twitter account (we used separate accounts for each simulation running in parallel).

It might even be a useful tool for tweeting your mind without leaving the shell:

~$ rm -rf .
~$ # Oh crap, didn't mean to do that.
~$ tweet 'Note to self: be MUCH more careful with "rm -rf"'

More details and source code available at the repository on Github.