Monday, June 12, 2006



The Saga of Thunderbird
Or
How I got a 17 Page Sig


This is where we see how I work through a trivial problem occuring in a trivial project for an equally trivial purpose. The journey, for me at least, is amusing.

I’ve been bored with my simple mail sig for a while, so I thought about writing a script to rotate the quote that appears below my contact information.

No big deal, I thought. I’ll just script up a sig file maker. Thunderbird should have no problem dealing with the output of a script as the sig, right?

Well, not really.

This is a Windows system, so I decided to write the script in Ruby. If you haven’t used Ruby, it’s a handy language in the vein of Perl and other scripting languages. The main reason I decided on Ruby instead of Perl is that Ruby has a really good implementation for Windows that works exactly like you’d expect it to and Perl can have some quirks in Windows (not for anything this simple, but I use Perl for *nix and I’ve started using Ruby in Windows).

My script, when it began, consisted of a few things – an array of strings that is approximately 17 pages long (I have a lot of quotes), a puts statement that outputs my contact information, and a line that outputs a random quote from the array.

After finishing the script, I change my account settings in Thunderbird to use the script, thinking that it would just take the output and use that. Stupid assumption on my part (and I honestly admit that). It took the whole file as a sig. That’s right – I had a 17 page sig.

Just what everyone wants – 20k of quotes tacked onto the end of a less than 1k email.

Next, I try explicitly launching Ruby and feeding it the script in my account settings. This, not surprisingly, doesn’t work either, but it was worth a shot.

Well, that’s not going to work, so after thinking for a second, I decide that the next best thing would be to have a new sig for every time Windows starts. This being the case, I try to add the script with the output redirected to a text file (which Thunderbird will read correctly) into the startup routine for logging on to Windows.

Can’t do that. Windows doesn’t like having the re-direct as part of the shortcut.

So much for the quick and dirty way. Time for the almost as quick and not quite so dirty way.

I go back to the script, make a line to open a file, take out the puts statements, replace them with write statements that write to the file, and close the file.

It now works, Windows runs it on startup, and I have a new quote for my sig when I want it.

What’s so funny about this? That’s how I was going to do it in the first place, but I thought I’d save myself a tiny little bit of typing by doing it the “easy” way.

Consider it a lesson learned. Or should I say a lesson re-learned since we all seem to have to go through this one once in a while.

Hey, at least it was on a quick little project instead of something buried deep inside a complex program.

Current mood: amused
Current music: Dirty Vegas – A Million Ways

No comments: