Hi All
I'd like to obtain a seed value (for a pseudorandom number generator) from
/dev/random, but when I try:
RAND =: '/dev/random'
read =: 1!:1
seed =: read < RAND
... I seem to get a null string. What am I doing wrong? (I'm using Ubuntu
Linux v 12.10 and J701/2011-01-10/11:25). In Perl (this works on my
machine), I'd say:
#!/usr/bin/perl
open(RAND, "/dev/random") or die "Can't open dev/random\n";
read(RAND, $seed, 4);
close(RAND);
print("Value is ", unpack("H*", $seed), "\n");
I've tried running J from the command line under sudo just in case there
was some 'security' issue, but this did nothing different. I'm not even
sure if this is something to do with formatting, or inability to access
/dev/random --- I suspect the former. When I say 3!:0 seed, I get type 2
(literal). If I use e.g. rf =: 1!:21 < '/dev/random' I obtain a file
number, but I get the same null result on reading it, and an indexed read
fails as expected. I can't find anything on /dev/random on the J website.
Regards Jo.
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm