I'm running the following command to generate a random password in a KSH script on a RHEL Linux VM but for some reason the cmd is not being closed and it's causing problems on the host.
The code worked as expected but the side effects were definitely unexpected. Any idea how I can enhance this to ensure the urandom stream gets closed after it's been called and therefore prevent the server from becoming overloaded?
Many thanks.
/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
in lieu of cat. Or, why not use bash's $RANDOM variable?
You are right that head should send a SIGPIPE to fold that should send a SIGPIPE to tr that should send a SIGPIPE to cat.
And each program in the chain should terminate.
It's not reliable though, a signal *can* get lost, especially if the system is very busy. If this also happens on an idle system then there is a bug somewhere (in one of the programs or in the shell's pipe handling).
In one of my old scripts (using /bin/sh for many LUnix platforms) I had limited it with
and, for safety, if the resul string was too short, I repeated it in a loop.
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)
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)
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)
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)
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)
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)
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)
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)