Sponsored Content
Top Forums UNIX for Advanced & Expert Users Cmd 'cat /dev/urandom' not closing cleanly Post 302994402 by RudiC on Wednesday 22nd of March 2017 01:01:28 PM
Old 03-22-2017
/dev/random supplies an seemingly infinite number of random bytes (in fact limited to 32MB since linux 3.16), so your cat won't finish soon if at all,as the random generator won't send an EOF.
Quote:
/dev/random will return at most 512 bytes
(c.f. man random), so you might want to read that, of limit the byte count yourself, e.g. by using
Code:
dd if=/dev/urandom count=40 bs=1

in lieu of cat. Or, why not use bash's $RANDOM variable?
This User Gave Thanks to RudiC For This Post:
 

8 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

/dev/urandom

Hi, how do I use /dev/urandom to generate a single number between 1-100? I can od /dev/urandom but it gives me an endless list of random numbers, I just want 1 between 1-100. How can I get that? Thanks. (12 Replies)
Discussion started by: Takumi
12 Replies

2. Solaris

What is /dev/tty /dev/null and /dev/console

Hi, Anyone can help My solaris 8 system has the following /dev/null , /dev/tty and /dev/console All permission are lrwxrwxrwx Can this be change to a non-world write ?? any impact ?? (12 Replies)
Discussion started by: civic2005
12 Replies

3. UNIX for Dummies Questions & Answers

cat /dev/null

Hi, Excuse my ignorance here - I'm a networks man and my knowledge of all things unix is somewhat limited. We have a very large file (/var/tmp/mond.log) that we need to zero - does the "cat /dev/null > /var/tmp/mond.log" command achieve this? (4 Replies)
Discussion started by: freakydancer
4 Replies

4. Slackware

Can't play sound files with aplay or cat to /dev/dsp

I am having problems using soundes. Until a few moments ago the following commands produced errors and no sound: cat /usr/share/apps/kolf/sounds/blackhole.wav/ > /dev/dsp yielded: /dev/dsp: Invalid argument cat /usr/share/apps/kolf/sounds/blackhole.wav > /dev/audio yelded: /dev/audio:... (3 Replies)
Discussion started by: slak0
3 Replies

5. Shell Programming and Scripting

Error output of cat to /dev/null

Hello, I'm trying to send the error output of a 'cat' operation to /dev/null like this: cat /dirA/dirB/temp*.log > /dirA/dirB/final.log 2>/dev/null This works perfectly in a terminal, but not when placed in a script. If there are no files matching temp*.log the script outputs an error... (7 Replies)
Discussion started by: Nils88
7 Replies

6. Shell Programming and Scripting

Memory fault(coredump) while using cat cmd

i have few log files that are input to my perl script... i am executing the script as below cat RTR*.log | test.pl and getting the following error -ksh: 25014: Memory fault(coredump) cat: write error: Connection reset by peer can anyone help me on this.... Thanks in... (2 Replies)
Discussion started by: niteesh_!7
2 Replies

7. UNIX for Beginners Questions & Answers

Cleanly log out a user w/o killing process

My AIX-based accounting program runs an end-of-day process that requires all users to be logged out. Sometimes I have a user that leaves for the day and forgets to logout. Is there any way I can cleanly log a user out without killing their process? (4 Replies)
Discussion started by: DLS1701
4 Replies

8. 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(4)						   BSD Kernel Interfaces Manual 						 RANDOM(4)

NAME
random , urandom -- random data source devices. SYNOPSIS
pseudo-device random DESCRIPTION
The random device produces uniformly distributed random byte values of potentially high quality. To obtain random bytes, open /dev/random for reading and read from it. To add entropy to the random generation system, open /dev/random for writing and write data that you believe to be somehow random. /dev/urandom is a compatibility nod to Linux. On Linux, /dev/urandom will produce lower quality output if the entropy pool drains, while /dev/random will prefer to block and wait for additional entropy to be collected. With Yarrow, this choice and distinction is not necessary, and the two devices behave identically. You may use either. OPERATION
The random device implements the Yarrow pseudo random number generator algorithm and maintains its entropy pool. Addditional entropy is fed to the generator regularly by the SecurityServer daemon from random jitter measurements of the kernel. SecurityServer is also responsible for periodically saving some entropy to disk and reloading it during startup to provide entropy in early system operation. You may feed additional entropy to the generator by writing it to the random device, though this is not required in a normal operating envi- ronment. LIMITATIONS AND WARNINGS
Yarrow is a fairly resilient algorithm, and is believed to be resistant to non-root. The quality of its output is however dependent on regu- lar addition of appropriate entropy. If the SecurityServer system daemon fails for any reason, output quality will suffer over time without any explicit indication from the random device itself. Paranoid programmers can counter-act this risk somewhat by collecting entropy of their choice (e.g. from keystroke or mouse timings) and seeding it into random directly before obtaining important random numbers. FILES
/dev/random /dev/urandom HISTORY
A random device appeared in Linux operating system. Darwin September 6, 2001 Darwin
All times are GMT -4. The time now is 10:32 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy