12-28-2008
random number generation in ksh
i tried to use $random function in unix
i simply typed print $random at shell and it returnted no value
is there any function in korn shell that i can use to generate random number
help is appreciated
10 More Discussions You Might Find Interesting
1. AIX
hello
I must to create a ksh script to give a random password with letter, number, and 8 digits.
I can't use the random command with ksh, there is a similar command ?
thank you (1 Reply)
Discussion started by: pascalbout
1 Replies
2. Programming
Hi...How can I generate random numbers between a given range ...preferably between 1 and 100...in UNIX C programming...?
I tried out functions like rand(),drand48() etc but didnt get satisfactory results...
Thanks a lot in advance.......... (1 Reply)
Discussion started by: tej.buch
1 Replies
3. UNIX for Dummies Questions & Answers
Hi all,
I have a doubt in SQL Loader.
We have SEQUENCE function in SQL Loader or can create Sequence in Oracle database for generating a number sequence for
a column while loading data using SQL Loader into table or multiple tables.
My requirment is this.
For the first run in SQL... (2 Replies)
Discussion started by: vinoth_kumar
2 Replies
4. UNIX for Dummies Questions & Answers
I need to generate a random number in ksh everytime I run the script ,the range should be from 100 to 24800,I could use $RANDOM but I seem to have no control over the range of numbers ,could you please suggest some way I could implement this .Thanks.
Mervin (2 Replies)
Discussion started by: mervin2006
2 Replies
5. Shell Programming and Scripting
Hi Folks,
Can you help me with this issue:
I have to generate the numbers say from 1001 for each record in a file based on a key field,
the catch is the generated number should be unique based on key column.
(EMP_NUMBER)
Example:
Input File:
EMP_NUMBER EMP_NAME
8908 ... (6 Replies)
Discussion started by: sbasetty
6 Replies
6. Shell Programming and Scripting
Hi
I have the below code
MAXCOUNT=10
count=1
echo
echo "$MAXCOUNT random numbers:"
echo "-----------------"
while # Generate 10 ($MAXCOUNT) random integers.
do
number=$ + 1 ]
"echo $number"
let "count += 1" # Increment count.
done
But aftre executing this
... (8 Replies)
Discussion started by: lalitka
8 Replies
7. Shell Programming and Scripting
How do I create a random number between 1 and 10 in kornshell? (2 Replies)
Discussion started by: dangral
2 Replies
8. Shell Programming and Scripting
Hi - I have a word GTTCAGAGTTCTACAGTCCGACGAT
I need to extract all the possible "chunks" of 7 or above letter "words" from this.
SO, my out put should be
GTTCAGA
TTCAGAG
TCAGAGT
CAGAGTTCT
TCCGACGAT
CAGTCCGACG
etc.
How can I do that with awk or any other language? I have no... (2 Replies)
Discussion started by: polsum
2 Replies
9. Programming
How can I choose randomly the row numbers of my file in awk? (4 Replies)
Discussion started by: Homa
4 Replies
10. AIX
Hello,
I have created a script to generate a random password on Linux/Solaris, but I simply cannot use it on my AIX VMs since Bash isn't installed on them.
I need a password that is randomly created with the following... (12 Replies)
Discussion started by: gfroute
12 Replies
LEARN ABOUT MOJAVE
getentropy
GETENTROPY(2) BSD System Calls Manual GETENTROPY(2)
NAME
getentropy -- get entropy
SYNOPSIS
#include <sys/random.h>
int
getentropy(void *buf, size_t buflen);
DESCRIPTION
getentropy() fills a buffer with random data, which can be used as input for process-context pseudorandom generators like arc4random(3).
The maximum buffer size permitted is 256 bytes. If buflen exceeds this, an error of EIO will be indicated.
getentropy() should be used as a replacement for random(4) when random data derived directly from the kernel random byte generator is
required. Unlike the random(4) pseudo-devices, it is not vulnerable to file descriptor exhaustion attacks and is available when sandboxed or
in a chroot, making it more reliable for security-critical applications.
However, it should be noted that getentropy() is primarily intended for use in the construction and seeding of userspace PRNGs like
arc4random(3) or CC_crypto(3). Clients who simply require random data should use arc4random(3), CCRandomGenerateBytes() from CC_crypto(3),
or SecRandomCopyBytes() from the Security framework instead of getentropy() or random(4)
RETURN VALUES
Upon successful completion, the value 0 is returned; otherwise the value -1 is returned and the global variable errno is set to indicate the
error.
ERRORS
getentropy() will succeed unless:
[EINVAL] The buf parameter points to an invalid address.
[EIO] Too many bytes requested, or some other fatal error occurred.
SEE ALSO
arc4random(3) CC_crypto(3) random(4)
HISTORY
The getentropy() function appeared in OSX 10.12
BSD
October 2 2015 BSD