#!/bin/csh ############################################################### # This script prints a random number between 1 and the # number passed in as an argument. # It returns 0 on success, nonzero on failure. ############################################################## ############################################################## # Argument checking # Make sure they passed in a parameter set maxnum = $1 if (0 == `echo -n "$maxnum" | wc -c`) then echo Usage: $0 maximum_number exit 1 endif # Make sure that it is a number larger than zero if (0 >= "$maxnum" ) then echo Usage: $0 maximum_number exit 1 endif ############################################################## # Pick one based on the number of nanoseconds mod the largest # number. Then add one to that to make it go from 1 through # the number itself. @ num = ( `date +%N` / 1000 ) % $maxnum @ num ++ echo $num exit 0