Date: Mon, 16 Jun 2003 11:48:26 -0500 From: "Jack L. Stone" <jackstone@sage-one.net> To: Matthew Seaman <m.seaman@infracaninophile.co.uk> Cc: freebsd-questions@freebsd.org Subject: Re: Running a rand or random script Message-ID: <3.0.5.32.20030616114826.01386ca0@sage-one.net> In-Reply-To: <20030616163235.GB33582@happy-idiot-talk.infracaninophile.c o.uk> References: <3.0.5.32.20030616111517.0137e538@sage-one.net> <3.0.5.32.20030616111517.0137e538@sage-one.net>
next in thread | previous in thread | raw e-mail | index | archive | help
At 05:32 PM 6.16.2003 +0100, Matthew Seaman wrote: >On Mon, Jun 16, 2003 at 11:15:17AM -0500, Jack L. Stone wrote: >> 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' between >> 00001-99999 >> >> Anyone have thoughts on how to do this....?? > > perl -e 'printf "%0.5d\n", int(rand(99999) + 1);' > >Assuming that range is inclusive. > > Cheers, > > Matthew > >Nb. Don't use srand() explicitly --- perl will auto-seed the PRNG from >/dev/urandom if left to it's own devices. > >-- >Dr Matthew J Seaman MA, D.Phil. 26 The Paddocks > Savill Way Matthew: Your one-liner is just exactly what I needed. THANKS! Best regards, Jack L. Stone, Administrator SageOne Net http://www.sage-one.net jackstone@sage-one.net
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3.0.5.32.20030616114826.01386ca0>