HPE GreenLake Administration
- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- random number
Operating System - HP-UX
1834149
Members
2852
Online
110064
Solutions
Forums
Categories
Company
Local Language
back
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
back
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Go to solution
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-18-2003 06:38 AM
03-18-2003 06:38 AM
im looking for a way to generate a random number. i dont want to add any packages except for the base installation of hp-ux. if theres no way to do it, i have access to gcc, but my C knowledge is quite limited. so help with an easy random number generator in c would also be apriciated.
Solved! Go to Solution.
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-18-2003 06:42 AM
03-18-2003 06:42 AM
Re: random number
You can do it with perl, which comes with HP-UX;
# random number from 0 to 255
perl -e 'srand(time() ^ $$); while (1) { print int(rand(1)*256); }' | dd bs=8k of=/tmp/tt count=100
# random number from 0 to 255
perl -e 'srand(time() ^ $$); while (1) { print int(rand(1)*256); }' | dd bs=8k of=/tmp/tt count=100
Im from Palmerston North, New Zealand, but somehow ended up in London...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-18-2003 06:44 AM
03-18-2003 06:44 AM
Solution
It couldn't be simpler, in the POSIX or Korn shell, ${RANDOM} is your boy.
You can also do things like
RAND=$((${RANDOM} % 100)) to restrict to a rangle 0-99.
There is also a more robust RNG in perl that is trivially easy to use.
You can also do things like
RAND=$((${RANDOM} % 100)) to restrict to a rangle 0-99.
There is also a more robust RNG in perl that is trivially easy to use.
If it ain't broke, I can fix that.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-18-2003 06:45 AM
03-18-2003 06:45 AM
Re: random number
Jim
There is an environment varialbe named RANDOM. Each time, each time you run it, you have a different number.
Try this at a comman prompt several times to see for yourself:
# echo $RANDOM
Hope this helps.
Hai
There is an environment varialbe named RANDOM. Each time, each time you run it, you have a different number.
Try this at a comman prompt several times to see for yourself:
# echo $RANDOM
Hope this helps.
Hai
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
Company
Events and news
Customer resources
© Copyright 2025 Hewlett Packard Enterprise Development LP