Automation made easy

Arguably one of the most common uses for shell scripting is the automation of mundane tasks. These tasks generally fall into two categories:

  1. Simple, fully automated processes
  2. Potentially dangerous, step-through processes

In the simple case, it is often desirable to log the success or failure of each step for later review in the event that something goes awry. In the latter case, it is common to prompt the user before each step and branch appropriately based on their response.

Both of these cases can be rather cumbersome to do in a scripting language like Bash, especially if you are unfamiliar with the argument passing and quoting rules of the language.

Many moons ago I created a little Bash include script which had some handy functions for handling these common tasks, and today I would like to introduce its standalone, grown up replacement: “Runt”.

Runt makes it easy to run commands and give useful output when it’s appropriate to do so (such as in error conditions). It also supports prompting the user interactively before executing a step. Let’s look at a few examples.

The most simple case is to run the command with a friendly description, and notify upon completion:

% runt -d "Updating APT repository" -- apt-get update
[INFO] Updating APT repository ...
[OKAY] Updating APT repository completed successfully!

For more dangerous commands, prompting the user may be appropriate. The user is given the chance to abort, or simply skip this particular step (while simulating success):

% runt -vi -d "Performing an APT upgrade" -- apt-get -yy upgrade
[INFO] Performing an APT upgrade ...
[INFO] Will execute: apt-get -yy upgrade

  Press ENTER to continue.
  Type "skip" and press ENTER to skip step.
  Type "info" and press ENTER for details.
  Or press Ctrl-C to abort.


[OKAY] Performing an APT upgrade completed successfully!
[OKAY] The output of the command was:

Reading package lists...
Building dependency tree...
Reading state information...
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

There are a number of options provided by Runt, including “terse” init-style output:

% runt -t -d "Checking for passwd" -- test -f /etc/passwd
 * Checking for passwd ...                                               [ ok ]

Of course, if something goes wrong, you’ll get more useful output:

% runt -t -d "Simulating an error" -- ls /not/a/real/path
 * Simulating an error ...                                               [ !! ]

[ERROR] Simulating an error exited with error (2)
[ERROR] The command executed was 'ls /not/a/real/path'
[ERROR] The output of the command was:

ls: cannot access /not/a/real/path: No such file or directory

[ERROR] Execution failed!

If no description is supplied (using -d), one will be made for you:

% runt -- test -f /etc/passwd
[INFO] Running 'test -f /etc/passwd' ...
[OKAY] Running 'test -f /etc/passwd' completed successfully!

Runt also supports executing commands on a remote server (via SSH):

% runt -s "" -- true
[INFO] Running 'true' ...
[INFO] Executing on server:
[OKAY] Running 'true' completed successfully!

Setting a working directory works on local and remote hosts:

% runt -v -w /etc -- ls passwd
[INFO] Running 'ls passwd' ...
[INFO] Command to execute: ls passwd
[INFO] Working directory: /etc

[OKAY] Running 'ls passwd' completed successfully!
[INFO] The output of the command was:


Detailed in-line help is also available:

% runt --help

Usage: ./runt [options] (command)


Hopefully someone is able to get a bit of use out of the tool. It’s proven useful to me in its various forms on a number of occasions during my career as a sysadmin.

If you’re interested, grab Runt 1.2 here. There is also a Runt 1.2 Debian package if that’s your poison.

Update: Runt has been rewritten as a Python script and additional functionality has been added (as of version 1.2).

Happy hacking!

The sanctity of marriage

In the late 1800’s, people fought to keep marriage defined as the joining of a man and woman of the same skin color. It wasn’t long ago that some people felt interracial marriage would ruin the “sanctity of marriage”.

Yesterday, that same spirit of intolerance, using the same flawed arguments, succeeded in passing an amendment to the California state constitution to retroactively invalidate the matrimony of any two people of the same gender.

The first amendment and article six of the constitution of the United States of America guarantee the separation of church and state by saying that no religion shall be unfairly recognized by the government.

Yesterday, the people of California ensured that the Christian bible’s supposed definition of marriage is the only one that can be recognized by the state of California by voting “yes” on Proposition 8. Yesterday, a blind eye was turned to the constitution by pandering to the desires the world’s largest, most influential cult.

1) This is an obvious repeat of the controversy surrounding interracial marriages. The same arguments being used then are being used now.

Just like the joining of a black man and a white woman was considered impure prior to Loving v. Virginia, the joining of a woman and another woman is being construed as impure today.

Only the word we use to describe this perceived impurity has changed; “miscegenation” has become “abomination”.

2) The majority of the funding for the Prop 8 campaign came from outside of the state of California.

Over $40 million in campaign funding came from the state of Utah alone (want to guess which institution?). It’s clear that the desires of the people of California are being trumped by a tyrannical outside party with deep pockets.

3) It is not the state’s place to define marriage.

If two consenting individuals want to make a contract between themselves to join in matrimony, that is their contract to make and the government’s job to uphold. If they wish to call that contract “marriage”, it is their right to do so, and the government’s job to recognize it.

4) The wedding of two people of the same gender doesn’t directly impact the rights of heterosexual couples.

Inevitably when I speak to supporters of Prop 8, they feel that they are being slighted. I’ve yet to hear a compelling argument for how gay marriage directly impacts their lives. Just a bunch of fear mongering that the “moral fabric” of our country will be destroyed.

Let me get this straight. Getting married to a stripper of the opposite sex in Vegas… OKAY. Getting married to someone you dearly love of the same sex… BAD. Loud and clear.

Gay people will continue to be gay regardless of if you let them marry the people they love. If ever there were an incredible uprising of gay pride, it will be in the aftermath of this unconstitutional marriage of church and state; the only marriage that can be considered a true abomination.

I’m hopeful that the U.S. Supreme Court’s tradition of curtailing the state’s unholy affairs with religion in favor of civil liberties will hold strong when presented with the opportunity to overturn Prop 8 and all equivalent state amendments.