Getting notified when a job is done

I really like the interaction of the command line with more advanced user interfaces. So today I got around to finally writing a little wrapper script for the mac, that notifies me with speech output when a program has finished using the say utility. The problem I was trying to solve was getting feedback when my command line build is done. Obviously I also wanted to know whether the build was successful or not. The first solution looked like this:

./build.sh && say success || say fail

That actually works quite nicely. But then I found it so useful, that I wrote a wrapper script, that returns an error when the wrapped program fails on top of the speech notification. It looks like this:

#!/bin/bash
fail ()
{
	say fail
        exit 1
}
 
eval $@ 
if [ $? -ne 0 ]; then
        fail
fi
say success

After placing this as tell in my path I can just go

tell ./build.sh
This entry was posted in Software Development. Bookmark the permalink.

2 Responses to Getting notified when a job is done

  1. I’ve been doing this for years for long running scripts.

    Try this 🙂

    say -v “bad news” “we’re very sorry the build has really failed”

  2. Derek Lewis says:

    I have a very similar script, called ‘pop’, that uses (on Linux) xosd-cat to pop up a message in red or green text. I find it indispensable.

Leave a Reply

Your email address will not be published. Required fields are marked *