#!/bin/ksh
#
# $Revision: 1.3 $ $Date: 2010-12-05 19:13:07-05 $
# $Source: /home/vogelke/projects/quote/RCS/getquote,v $
# $Host: sys7.com $
# $UUID: 1375b26b-7a6e-3a1b-91a6-f52f2f64d3fe $
#
#<getquote: pick a random entry from my quotes file.

PATH=/usr/local/bin:/usr/bin:/bin
export PATH
qfile="$HOME/.quotes.cdb"
test -f "$qfile" || exit 1

max=$(cdbget 0 < $qfile)
sec=$(date '+%s')
r=$(/usr/bin/od -vAn -N1 -tu1 < /dev/urandom)  # 0-255
k=$(( ($sec + $r) % $max + 1))
exec cdbget $k < $qfile
exit 2
