Running a rand or random script

Jack L. Stone jackstone at sage-one.net
Mon Jun 16 09:50:31 PDT 2003


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 at sage-one.net


More information about the freebsd-questions mailing list