Hacking

Matts on 2007-06-01T03:52:59

Some days it's good to be a hacker.

For a long time I've had fetchmail running at work to download all mail from our Exchange server (which has IMAP enabled), run through procmail (for filtering into folders) delivering to my Maildir folders.

But every so often it would just hang.

So I wrote a job to kill fetchmail every 3 hours. But this bugged me - why should I have to hack around someone's broken software? Sadly the platform I was running it on had to be Red Hat 8 (for various work reasons), and upgrading fetchmail didn't seem to be an option.

So I wrote my own "fetchmail". 30-ish lines of perl using Net::IMAP::Simple and job done.

Unsurprisingly it has yet to hang.


wtfsubject

educated_foo on 2007-06-01T04:39:00

So I wrote my own "fetchmail"
Dude, you are the next Eric Raymond. But with fewer bugs. And probably fewer guns. PHEAR ME IDIOTARIANS!!!

Nice Story + My Hacks

Shlomi Fish on 2007-06-01T10:42:32

Nice story - I'm glad you found a solution. You probably realise that the current Fetchmail (no longer maintained by ESR) probably has these things fixed, and that the Perl Fetchmail-replacement you wrote has a very small subset of the Fetchmail features, and as such is not an accurate replacement. It works for you, but most people will not find it an accurate replacement.

I believe many programmers wrote ad-hoc replacements for popular programs. For example, I wrote my own RSS/Atom aggregator based on XML::Feed and other modules because after I installed Plagger (a very painful process, I might add - it requires half of CPAN), I found it didn't have the feature of limiting the number of items in the feed. (Which was very trivial to implement in my opinion). The GPL and any other free software licence allows you to use free code for your own internal use and even modify it without releasing your modifications to the public.

Latemp evolved from a large amount of custom logic that I prepared for my own sites, by copy-and-pasting it. Eventually, I decided to concentrate everything in one place to avoid redundancy and also decided to publish it as what Joel Spolsky calls "shrinkwrap". Shrinkwrap (open-source or otherwise) requires more discipline than something ad-hocish you keep for yourself, but is more fun and rewarding. (I know very few people who have used Latemp besides me, but it's still there.)

Eric Sink also talked about it when he said how he dumped the unmaintained CityDesk, for a custom CMS he hacked in .NET in a relatively small amount of time.

I also wanted to write something about how programming may eventually become an essential skill, because non-programmers will find it harder and harder to use a computer without learning how to program. Many things nowadays are kind-of-like-programming: Spreadsheets (Excel, etc.), HTML (and CSS), designing levels for games, MS Access and friends, etc. These can and often do serve as a useful stepping stones to real, Turing-complete programming. And programming is not as hard as people often think, and most of them just have prejudice against it.

Microsoft has desperately been trying to save people from becoming programmers, and the end result was the 9 milliard dollars, behind-schedule, sub-standard, buggy and otherwise extremely bad Vista. If anyone does a little programming on his own or at least hires someone to do some trivial programming for him, then we won't need to throw milliards of dollars down the drain, or pay for overpriced software like Microsoft's.

Re:Nice Story + My Hacks

sigzero on 2007-06-01T11:59:50

Nice story - I'm glad you found a solution. You probably realise that the current Fetchmail (no longer maintained by ESR) probably has these things fixed, and that the Perl Fetchmail-replacement you wrote has a very small subset of the Fetchmail features, and as such is not an accurate replacement. It works for you, but most people will not find it an accurate replacement.

I think he mentioned upgrading wasn't an option. I also didn't catch where he said that he created his own "feature complete" version of fetchmail. He hacked up a "fetchmail" to do what he needed it to do (probably no more and no less). This is one of the points of Perl. : )

Re:Nice Story + My Hacks

Shlomi Fish on 2007-06-01T13:13:51

I think he mentioned upgrading wasn't an option. I also didn't catch where he said that he created his own "feature complete" version of fetchmail. He hacked up a "fetchmail" to do what he needed it to do (probably no more and no less). This is one of the points of Perl. : )

I know he said upgrading wasn't an option. However, assuming his work constraints were not as silly as requiring RedHat 8, then everything probably would have worked as it is. See this fortune file (search for "Mozilla") for me and others mocking the fact that some people are still using ancient software due to their work constraints.

In regards to being "feature complete", maybe I phrased my original post in a bad way, but I knew he knew it wasn't as feature-complete as Fetchmail. What I meant was that it was not as good as fetchmail is (which was implied by what he said, but not explicitly noted), and what the implications of these are.

I should note that often such in-house and/or ad-hoc software has to be extended until it becomes much more featureful. A lot of things don't stay simple forever. But of course, using Perl you can make sure this ad-hoc software will be easy to extend and enhance well into the future.

Re:Nice Story + My Hacks

sigzero on 2007-06-01T13:20:30

I am stuck on Perl 5.6.0 at the moment myself. I am looking at getting the project over to 5.8 but that is what I am stuck with at the moment. : )

Re:Nice Story + My Hacks

btilly on 2007-06-01T14:24:17

He didn't say that it was "as good as" Fetchmail. He said that for his needs it was better. :-)

Damn it feels good to be a Hacker.

stu42j on 2007-06-01T14:23:59

Now I have that song from Office Space stuck in my head.

even more hackerish

jmason on 2007-11-28T11:54:54

I just said "I could mail Matt, or I could write my own too". guess which option I took. NIH! ;)

(mind you mine came out as 272 lines, but that's with a config file parser and support for deleting messages from some folders, while keeping messages in others and using SHA1 of the TOP output to track seen messages -- ie. the feature that my fetchmail doesn't do....)