Running a rand or random script
Matthew Seaman
m.seaman at infracaninophile.co.uk
Mon Jun 16 09:32:47 PDT 2003
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
PGP: http://www.infracaninophile.co.uk/pgpkey Marlow
Tel: +44 1628 476614 Bucks., SL7 1TH UK
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 187 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-questions/attachments/20030616/143ef066/attachment.bin
More information about the freebsd-questions
mailing list