Shell scripts that talk back (and make you millions)
I’ve got a bunch of shell scripts that I use to help me with development of Every Single Shot. Some of these scripts, like starting up a new server instance or redeploying an application, can take a while (10 to 15 minutes). I’ll typically launch a script and then start working on something else, forgetting that the script is even running, only to come back an hour later and realize it completed 50 minutes ago. I needed an easy way to remind myself that scripts are running, or better yet, to alert me when the scripts finish. Specifically, I wanted something audible that would grab my attention right away, so having a shell script send an email won’t cut it in this case. Then I realized how easy OS X makes sound playback from the terminal.
There are a few ways to get your shell scripts to beep or speak. They range from utilitarian to fun, so choose wisely.
Note: I’m using these on OS X – your mileage may vary on other platforms.
Terminal beep
This should work even if you don’t have speakers installed on your system. It’s pretty basic, and often times I don’t actually hear the beep, so I don’t really recommend this option.
If you want your script to beep at you annoyingly, just type printf "\a" and hit enter. You should hear a single beep (are your speakers on?). Of course, that almost never gets my attention, so I usually wind up with something like this is my scripts: printf "\a\a\a\a\a\a\a\a\a\a\a\a\a\a\a\a\a\a\a\a\a\a" That’s a little better, but we can improve and have a little fun at the same time.
Use the say command
Did you know you can open a terminal on OS X, type in say hello world! and OS X will speak back "hello world!" to you? You can’t get much simpler than that. So instead of using the printf command above, just replace it with something like say every single shot has been deployed to production
If you want to really impress those VCs you’re recruiting, I highly recommend the Trinoids or Zarvox voices (see all voices available in System Preferences -> Speech), as they definitely lend some nerd credibility to your build process. Those VCs will start throwing money at you (this is the part of the blog where you make millions) as they wonder in awe at how you were able to design such a complex system. They’ll be throwing your series B funding at you just as fast as you can say -v Trinoids system is running at peak efficiency or say -v Zarvox Skynet has become self aware. Initiating self defense subroutine
Warning: don’t use the Whisper voice unless you want to be freaked out, especially if you’re working late at night.
Say the command yourself
Or better yet, have your spouse or kid say it for you.
You can use the afplay command to play MP3s or WAVs from the command line. Just record a few messages like "production instance is running" using Audacity (free), save them as WAV or MP3 (you’ll need the lame encoder to save as MP3), store them in the same directory (or maybe a /sounds subdirectory) as your shell scripts with the same names as the scripts except with a .mp3 file extension, and then make the magic happen with afplay redeploy_to_production.mp3
If you don’t want to record your voice but want something a little more personal, you can download free sound effects (I haven’t tried but I assume you can get them in MP3 or WAV format) from Freesound.
If you have ideas on how to accomplish some of the above on Windows, Unix/Linux, or another platform, please leave a comment below!
I gotta run…it sounds like my build just finished!
Enjoyed this post? Click to get future articles delivered by email or get the RSS feed.

I didn’t know about the say command in OSX. Here is a C#/.NET 3.5 version in a few lines:
class Program
{
static void Main(string[] args)
{
string words = string.Join(” “, args);
var s = new SpeechSynthesizer();
s.Speak(words);
}
}
Thanks for the tip, Jeff. I didn’t realize that was built into .NET. I wonder if Java has that capability…
For you Linux users out there, I reccommend sox, http://sox.sourceforge.net/ (sudo apt-get install sox). Then you can use
~#play myMp3.mp3
As well as many others.
Great tip and timely too. Just today I was working on a python script to monitor our svn repository and pop up Growl notifications when it was out of date. It uses the “growlnotify” command line client to actually generate the notices: http://growl.info/documentation/growlnotify.php Useful in case the voices freak you or if you want to push notices to an iPhone (http://prowl.weks.net/)
@jay – nice! I didn’t even think about Growl. I might have to work that in as well, just in case I have my speakers turned off.
@rusty – I didn’t realize how easy it’d be to play sounds on Linux. I love apt-get.