- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: puzzle no - 2
Categories
Company
Local Language
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
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
Community
Resources
Forums
Blogs
- 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
08-15-2002 09:01 PM
08-15-2002 09:01 PM
Can anybody write a shell script which can
generate random numbers and append to a output
file ?.
CONDITION: Should NOT use echo $RANDOM
regards,
U.SivaKumar
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-15-2002 11:07 PM
08-15-2002 11:07 PM
Re: puzzle no - 2
Try these:-
Get a randon number in scripts
NOTE: produce a number 0 - $LIMIT-1
nawk:
set num=`nawk 'BEGIN { srand();
printf "%d", rand()*$LIMIT
}' /dev/null`
date:
set date=`date +%j%H%M%S`
set num=`expr $date \% $LIMIT`
(k/z/ba)sh
$RANDOM produces a number from 0.0 to 1.0
-----------------------------------------------------
Use a psudo random number generator
#!/bin/csh -f
#
# Random limit -- produce random number from 1 to limit
#
set multiplier = 25173
set increment = 13849
set modulus = 65536
set seedfile = $HOME/.rnd # seed file to use
if ( ! -f $seedfile ) then
echo '17' > $seedfile
endif
@ number = ( `cat $seedfile` * $multiplier + $increment ) % $modulus
echo $number > $seedfile
@ number = $number % $1 + 1
echo $number
Paula
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-15-2002 11:10 PM
08-15-2002 11:10 PM
Re: puzzle no - 2
perl -e 'srand(time()^$$);while (1){print int(rand(1)*255);}'
This will print random numbers from 1-255 seeded by the current time when invoked, you can redirect output to a file. You will need perl installed though.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-16-2002 06:00 AM
08-16-2002 06:00 AM
Re: puzzle no - 2
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-16-2002 06:18 AM