#!/bin/csh -f

# åեγǧ
if (-e /tmp/man.lock) then
	echo "Sorry, I'm busy now...."
	exit
endif
touch /tmp/man.lock

# ץȤν
set CAT="/bin/cat"
set WC="/usr/bin/wc"
set AWK="/usr/local/bin/jgawk"
set RAND="/usr/local/bin/rand"
set MAN="/usr/bin/man"
set SED="/usr/local/bin/jsed"
set RM="/bin/rm"
set TR="/usr/bin/tr"
set MANLIST="/home/xxx/manlist.txt"
set ALLMAN=`$CAT $MANLIST | $WC -l`
set RANDMAN=`$RAND $ALLMAN`
set MANNAME=`$AWK 'NR=='"$RANDMAN"' {print $1}' $MANLIST`

# ϤԽ
$MAN -P $CAT -a $MANNAME | $SED -f /home/xxx/public_html/randman.sed | $TR -s "\012" 

# åեκ
$RM /tmp/man.lock

