[clue-tech] $RANDOM quality.

Keith Hellman khellman at mcprogramming.com
Sun Apr 17 15:49:01 MDT 2005


On Sun, Apr 17, 2005 at 01:51:27PM -0600, David Anselmi wrote:
> How's that for a way to turn a 5 minute (or less) "give me a random IP" 
> into an afternoon?

For completeness sake, I'll mention that 
  $ RANDOM=3
is how you seed the generator.

I've used ${RANDOM} often when writing scripts to autorun unittests on
C code.  I once needed a way to automatically generate a fake
"directory" of human names vs IP address...

I used the system dictionary (part of the ispell package I suspect)
and ${RANDOM} in a 10 line bash script.  Most of the names were
understandably gibberish -- but the ones that weren't were always a
hoot. I had more fun testing that software than any other :^)
 

-- 
Keith Hellman                             #include <disclaimer.h>
khellman at mcprogramming.com                from disclaimer import standard
public key @ www.mcprogramming.com


"While it might seem that a simple increment operator is an atomic
operation, there's no gaurantee that it is.  It's actually possible for
Thread 1 to update half of a 32-bit x while Thread 2 reads the full 32
bits, getting a mishmash instead of a valid integer.  (And that's only
one thing that can go wrong.  Another is that compiler optimization might
leave the integer in a register.  You really can't ever let threads
simultaneously access data without protection.)"

-- Marc J. Rochkind, *Advanced Unix Programming*, Second Ed.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://cluedenver.org/pipermail/clue-tech/attachments/20050417/a3f4b8ed/attachment.bin


More information about the clue-tech mailing list