Archive

Posts Tagged ‘scripting’

Don’t forget StdErr

March 28th, 2009

I recently ran into an issue where a WSH script was calling an external executable and returning an exit code of 0 even though there had been an error running the external executable. The problem is that I was relying on oExec.StdOut.ReadAll() to block the script until the command had finished processing. The ReadAll() method functions synchronously, so if the executable had been writing to StdOut, I would have been right. Unfortunately, I was neglecting the StdErr stream. So, not only did I miss the errors that the executable threw, the script didn’t block on the executable’s output, so I returned the exit code before the executable had actually finished running. The lesson here is to always think about StdErr no matter what you’re trying to accomplish.

Technology , ,

SpamAssassin: Dealing with unrecognized spam

May 3rd, 2008

Everyone hates spam, and one of the main ways that people are fighting it is through the use of SpamAssassin. I’ve been using it for a while now and have Sieve detecting spam headers and moving them to my Junk folder.

The Problem

Dealing with spam that went unrecognized has been more of a manual process. Every once in a while, I’d have to segregate all of my useful mail from the spam and run “sa-learn” on the leftovers. This isn’t horrible, because I tend to shell into my server fairly frequently, but I really prefer to have menial tasks like this automated.

A solution

First of all, I created a folder in my mailbox called “Unrecognized Spam”. The name isn’t important, really. It just needs to be a place to file away all of those messages that SpamAssassin didn’t catch on the way in.
Once that was done, I wrote a very simple little script, which I dropped in /etc/cron.daily/:

Read more…

Technology , , , ,