random number generator

Mike Matthews matthews at is-next.umd.edu
Sat Dec 29 11:24:42 AEST 1990


I'm trying to make a random sound player for my NeXT, using a shell script and
crontab.local.  I have everything working just fine, except for one small thing:
the random numbers aren't really random.  They always start at the same thing.
Now, I know a little about how this works, and I know it has something to do
with setting the seed (or the state -- I'm using the newer random() function),
but how can I set *that* randomly every time the script is run?

I essentially do a set num=`random <lo mark> <hi mark>`, then a
/usr/bin/sndplay /usr/local/snds/$num.snd, which works, but it always plays
the same sound...

Any help would be appreciated.  I was thinking I could just do a srandom(x)
but that would still be a "fixed" random marker, wouldn't it?  Please reply by
Email to matthews at is-next.umd.edu, and I will post the answer if/when I get it.

Thanks again,
Mike



More information about the Comp.unix.programmer mailing list