/dev/urandom


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers /dev/urandom
# 1  
Old 01-30-2007
/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.
# 2  
Old 01-30-2007
In ksh,
((i=($(dd if=/dev/urandom bs=2 count=1 2>/dev/null| od -tu2 | sed -n '1s/0* *0*//p')/(65536/(100-1)))+1))
should do it. (I think...)
# 3  
Old 01-30-2007
Do you happen to know the command in sh?
# 4  
Old 01-31-2007
The command "dd" should be on any UNIX box. sh should see it. What error are you getting?
# 5  
Old 01-31-2007
Antique shells do not have built-in arithmetic for one thing. I would switch to ksh (which has been around for over 20 years now).
# 6  
Old 01-31-2007
I tried it in ksh but nothing happens.

In sh it says: Syntax error: word unexpected (expecting ")")
# 7  
Old 01-31-2007
It doesn't print anything

run the command, then echo $i
 
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. 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

2. UNIX for Advanced & Expert Users

Cmd 'cat /dev/urandom' not closing cleanly

Hi 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. PASSWORD="$(cat /dev/urandom | tr -dc "a-zA-Z0-9" | fold -w 16 | head -1)Aa0!" The code worked as... (2 Replies)
Discussion started by: user052009
2 Replies

3. Red Hat

Changing grub from /dev/sda to /dev/sdb

Hi, Please suggest steps to change grub from /dev/sda to /dev/sdb, (1 Reply)
Discussion started by: manoj.solaris
1 Replies

4. Shell Programming and Scripting

Automating partitioning setup of /dev/sda on /dev/sdc

Objective: To recreate the partitioning setup of /dev/sda on /dev/sdc How would I parse the below information and initialize variables (an array?) that can be used to build sgdisk commands in a script, regardless of the number of partitions? Something along the lines of: sgdisk -n... (12 Replies)
Discussion started by: RogerBaran
12 Replies

5. AIX

Problem in /dev/hd1 and /dev/hd9var

Hello AIXians, I can't boot my AIX, it hangs and stops at the code error: 0518 After searching google, I knew the problem is due to problems in File Systems. So the solution is booting from any bootable media, then run these commands in maintenance mode: #fsck -y /dev/hd4 #fsck -y... (3 Replies)
Discussion started by: Mohannad
3 Replies

6. AIX

Difference between /dev/hdisk and /dev/rhdisk

Hi, How can i check that i am using RAW devices for storage in my AIX machine... Also after adding a LUN from storage to a aix host, when i check /dev in the host, i can see both rhdisk and hdisk with same number eg: dcback1(root):/dev>ls -lrt | grep disk12 crw------- 1 root ... (4 Replies)
Discussion started by: jibujacob
4 Replies

7. Solaris

Lun remove, stuck in /dev/dsk and /dev/rdsk

So, we removed a LUN from the SAN and the system is refusing to remove the references to it in the /dev folder. I've done the following: devfsadm -Cv powermt -q luxadm -e offline <drive path> luxadm probe All those commands failed to remove the path. The drive stills shows up as <drive... (13 Replies)
Discussion started by: DustinT
13 Replies

8. 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
Login or Register to Ask a Question