Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.milw.wisc.edu!bionet!ames!amdahl!pacbell!att!occrsh!uokmax!randy From: randy@uokmax.UUCP (Longshot) Newsgroups: comp.unix.questions Subject: Re: random numbers in a C shell script? Message-ID: <3138@uokmax.UUCP> Date: 5 May 89 18:52:48 GMT References: <1501@cmx.npac.syr.edu> Reply-To: randy@uokmax.UUCP (Longshot) Organization: University of Oklahoma, ECN Lines: 36 In article <1501@cmx.npac.syr.edu> gefuchs@logiclab.cis.syr.edu (Gill E. Fuchs) writes: - -Bon Jorno net, - -how would one go about getting a random numba in a C shell script? - -muchas randomas gracias No way that I could find. I wrote this tiny prg to allow me to do it: #include /* Return a random number between 1 and the argument given. */ main(argc,argv) register int argc; register char **argv; { int i; long time(),random(); srandom(time(0)); i = atoi(*++argv); i = ((int)random() >> 4) % i; printf("%d\n",++i); } I use it to randomly select a .signature when I log in. Randy -- Randy J. Ray University of Oklahoma, Norman, Oklahoma (405)/325-5370 !texsun!uokmax!randy randy@uokmax.uucp randy@uokmax.ecn.uoknor.edu "No one knows what it's like... to be the the bad man, to be the sad man.. behind blue eyes..." -The Who