Below is the computer program used to generate the random numbers for the second part of the project. It ran on Solaris 10, on a Sun v210 server.

#!/bin/ksh

#=============================================================================
#
# number_generator.sh
# -------------------
#
# Generate and email off a random number for painting project "fifty-eight
# percent".
#
# Requires a working mailx. Must be run as a user with cron privileges.
#
# R Fisher 03/08
#
# v1.0 Please record any changes below
#
#=============================================================================


#-----------------------------------------------------------------------------
# VARIABLES

MIN=1
    # Lowest acceptable number

MAX=116
    # Highest acceptable number

USED_TBL="/var/tmp/used_numbers.txt"
    # Where we record the numbers we've used. Takes the form
    # number:YYYY-MM-DD

MAILTO="someone@somewhere.com"
    # Where to mail the number

PATH=/usr/bin
    # Always set your PATH

CRONTMP="/tmp/cron$$"
    # Temporary file to be used when this script removes itself from the
    # crontab

#-----------------------------------------------------------------------------
# SCRIPT STARTS HERE

# If the used numbers table doesn't exist, create it to stop grep
# complaining

[[ -f $USED_TBL ]] || >$USED_TBL

# How many numbers have we done so far? If we've done them all, we're going
# to remove all traces of our existence.

USED=$(wc -l $USED_TBL | tr -dc [[:digit:]])
TOTAL=$(($MAX - $MIN + 1))

if [[ $USED -ge $TOTAL ]]
then
    crontab -l  | grep -v $0 >$CRONTMP
    crontab -r
    crontab $CRONTMP
    rm -f $0 $USED_TBL $CRONTMP
    exit 0
fi

# $RANDOM is from 0 to 32767, so chances are we won't be able to use the
# number. It may also already have been used

NUM=$RANDOM

while [[ $NUM -lt $MIN || $NUM -gt $MAX || -n $(grep ^${NUM}: $USED_TBL) ]]
do
    NUM=$RANDOM
done

# We've got the number. Let's add it, along with the date, to the used table
# file. Then we can mail out the number.

print ${NUM}:$(date "+%Y%d%m") >>$USED_TBL

mailx -s "Today's number..." $MAILTO <-EOMAIL

The number for $(date "+%A %e %B %Y") is:


                           $(print xx$NUM | sed 's/./=/g')
                            $NUM
                           $(print xx$NUM | sed 's/./=/g')

This is number $(($USED + 1)) of $TOTAL
-----------------------------------------------------------------------------
Generated by ${0##*/} running on $(uname -n).

EOMAIL

The HTML syntax highlighting was done using the

:runtime! syntax/2html.vim

command in Vim.