Re: Needing a random number generator for scripting
On Thu, Sep 27, 2001 at 10:55:50AM -0400, Noah Meyerhans wrote:
| On Thu, Sep 27, 2001 at 09:20:04AM -0400, dman wrote:
| > | /dev/random gives random bits. I don't know where it is documented.
| > | There is a system call random() (see man 3 random). You could write a
| > | wrapper C program to use it in scripts.
| >
| > Naw, just use python :-).
| >
| > #!/usr/bin/env python
| >
| > def my_randint() :
|
| <snip>
|
| > #!/usr/bin/env python
| > import random
| > print random.random() # this gives a float between 0 and 1
| > print random.randint( 0 , 10 ) # this gives an int between 0 and 10
| > # (the arguments)
|
| Why do you people insist on doing things the hard way? 'echo $RANDOM'
| in bash works as well as any of these solutions posted here...
I didn't know bash provided a way to get a random number. Thanks!
-D
Reply to: