Sponsored Content
Top Forums Shell Programming and Scripting Need to generate a file with random data. /dev/[u]random doesn't exist. Post 302844064 by Devyn on Friday 16th of August 2013 09:05:20 AM
Old 08-16-2013
Need to generate a file with random data. /dev/[u]random doesn't exist.

Need to use dd to generate a large file from a sample file of random data. This is because I don't have /dev/urandom.

I create a named pipe then:

Code:
dd if=mynamed.fifo do=myfile.fifo bs=1024 count=1024

but when I cat a file to the fifo that's 1024 random bytes:

Code:
cat randomfile.txt > mynamed.fifo;

the dd command exits writing only 1024 (Likely the EOF thing). so I never get my 1MB file. How do I get around this? How do I ensure it generates the random data file without closing dd? Is there something else I need to pass?

Cheers,
DH

Last edited by Scott; 08-16-2013 at 12:05 PM.. Reason: Code tags, please.
 

10 More Discussions You Might Find Interesting

1. Programming

How to generate a random number?

How to generate a random integer with specific range(for example, from 1 to 1000)? Also, how to convert a floating point number into a integer? (2 Replies)
Discussion started by: MacMonster
2 Replies

2. Shell Programming and Scripting

Generate a random password

Hello All... Can someone help me generate a random password which will be 7 characters long which contains alpha-numeric characters using shell script. I am looking to store the output of the script that generates the password to a variable within a script and use it as the password. ... (5 Replies)
Discussion started by: chiru_h
5 Replies

3. Programming

Generate Random Password in C

I need a function to generate a random alphanumeric password in C code. It needs to be between 6-8 characters and follow the following rules: Reject if same char appears # time: 4 or more Reject if same char appears consecutively: 3 or more I have the following random password working for... (2 Replies)
Discussion started by: vjaws
2 Replies

4. Programming

Generate random number

I saw this formula to generate random number between two specified values in shell script.the following. $(((RANDOM%(max-min+divisibleBy))/divisibleBy*divisibleBy+min)) Give a example in book. Generate random number between 6 and 30.like this. $(((RANDOM%30/3+1)*3)) But I have a... (1 Reply)
Discussion started by: luoluo
1 Replies

5. Programming

generate array of random numbers

hi guys, I am writing a c program that generates a two dimensional array to make matrix and a vector of random numbers and perform multiplication. I can't figure out whats wrong with my code. It generates a matrix of random numbers but all the numbers in the vector array is same and so is the... (2 Replies)
Discussion started by: saboture88
2 Replies

6. Shell Programming and Scripting

generate random base 16

How would you use bash to generate a random 32 digit number base 16? Like this one: 0cc06f2fa0166913291afcb788717458 (8 Replies)
Discussion started by: locoroco
8 Replies

7. UNIX for Dummies Questions & Answers

how to generate random number as as the first column of a txt file

Dear all, I have a question. I have a txt file say 4000 rows X 1800 Column. I 'd like to creat a new column as the first column which is a column of random numbers (n=4000) thanks a lot! Lin (2 Replies)
Discussion started by: forevertl
2 Replies

8. Shell Programming and Scripting

Generate random numbers in script

i want to generate a random number through a script, and even if anyone reads the script, they wont be able to figure out what the random number is. only the person who setup the script would know it. something like this could work: random the full thread is here: ... (13 Replies)
Discussion started by: SkySmart
13 Replies

9. Shell Programming and Scripting

Help with generate a pair of random number

Hi, Is anybody experience generate a pair of random number by using awk command? I wanna to generate a pair of random number (range from 1 to 4124) and repeats it 416 times. Desired output 2 326 123 1256 341 14 3245 645 . . . I did write the below command: awk... (5 Replies)
Discussion started by: perl_beginner
5 Replies

10. HP-UX

Dev/urandom and dev/random missing in HP-UX

Hi, In our HP-UX B.11.11. I could not find dev/urandom and dev/random Are all pseudo-devices implemented as device drivers, or in need to run /configure some package to install the package to have dev/urandom. Please help (4 Replies)
Discussion started by: rashi
4 Replies
random(7D)							      Devices								random(7D)

NAME
random, urandom - Strong random number generator device SYNOPSIS
/dev/random /dev/urandom DESCRIPTION
The /dev/random and /dev/urandom files are special files that are a source for random bytes generated by the kernel random number generator device. The /dev/random and /dev/urandom files are suitable for applications requiring high quality random numbers for cryptographic pur- poses. The generator device produces random numbers from data and devices available to the kernel and estimates the amount of randomness (or "entropy") collected from these sources. The entropy level determines the amount of high quality random numbers that are produced at a given time. Applications retrieve random bytes by reading /dev/random or /dev/urandom. The /dev/random interface returns random bytes only when suffi- cient amount of entropy has been collected. If there is no entropy to produce the requested number of bytes, /dev/random blocks until more entropy can be obtained. Non-blocking I/O mode can be used to disable the blocking behavior. The /dev/random interface also supports poll(2). Note that using poll(2) will not increase the speed at which random numbers can be read. Bytes retrieved from /dev/random provide the highest quality random numbers produced by the generator, and can be used to generate long term keys and other high value keying material. The /dev/urandom interface returns bytes regardless of the amount of entropy available. It does not block on a read request due to lack of entropy. While bytes produced by the /dev/urandom interface are of lower quality than bytes produced by /dev/random, they are nonetheless suitable for less demanding and shorter term cryptographic uses such as short term session keys, paddings, and challenge strings. Data can be written to /dev/random and /dev/urandom. Data written to either special file is added to the generator's internal state. Data that is difficult to predict by other users may contribute randomness to the generator state and help improve the quality of future gener- ated random numbers. By default, write access is restricted to the super-user. An administrator may change the default read/write restriction by changing the permissions on the appropriate special files. /dev/random collects entropy from providers that are registered with the kernel-level cryptographic framework and implement random number generation routines. The cryptoadm(1M) utility allows an administrator to configure which providers will be used with /dev/random. ERRORS
EAGAIN O_NDELAY or O_NONBLOCK was set and no random bytes are available for reading from /dev/random. EINTR A signal was caught while reading and no data was transferred. ENOXIO open(2) request failed on /dev/random because no entropy provider is available. FILES
/dev/random /dev/urandom ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability | SUNWcsr | +-----------------------------+-----------------------------+ |Interface Stability |Evolving | +-----------------------------+-----------------------------+ SEE ALSO
cryptoadm(1M), open(2), poll(2), attributes(5) NOTES
/dev/random can be configured to use only the hardware-based providers registered with the kernel-level cryptographic framework by dis- abling the software-based provider using cryptoadm(1M). You can also use cryptoadm(1M) to obtain the name of the software-based provider. Because no entropy is available, disabling all randomness providers causes read(2) and poll(2) on /dev/random to block indefinitely and results in a warning message being logged and displayed on the system console. However, read(2) and poll(2) on /dev/random continue to work in this case. An implementation of the /dev/random and /dev/urandom kernel-based random number generator first appeared in Linux 1.3.30. A /dev/random interface for Solaris first appeared as part of the CryptoRand implementation. SunOS 5.10 21 June 2004 random(7D)
All times are GMT -4. The time now is 04:01 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy