Date: Mon, 16 Jun 2003 18:42:42 +0200 From: Simon Barner <barner@in.tum.de> To: "Jack L. Stone" <jackstone@sage-one.net> Cc: freebsd-questions@freebsd.org Subject: Re: Running a rand or random script Message-ID: <20030616164242.GA529@zi025.glhnet.mhn.de> In-Reply-To: <3.0.5.32.20030616111517.0137e538@sage-one.net> References: <3.0.5.32.20030616111517.0137e538@sage-one.net>
next in thread | previous in thread | raw e-mail | index | archive | help
Hi,
> I need to run a script, perhaps using FBSD's 'rand' or 'random' command (=
or
> any other) that will generate one single 5-digit number 'at random' betwe=
en
> 00001-99999
>=20
> Anyone have thoughts on how to do this....??
Don't know about a shell way to do this, but what about this tiny
C program (compile and link with gcc -c -o r.o && gcc -or r.o)
#include <stdlib.h>
#include <time.h>
=20
int main (int argc, char *argv[]) {
srandomdev();
/* use this on non-BSD systems:
srandom(time (0));
*/
=09
unsigned int r =3D random () % 99999 +1;
printf ("%d\n", r);
=09
return r;
}
Cheers,
Simon
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20030616164242.GA529>
