Page 1 of 1 1
Topic Options
#422 - 1999-09-10 02:11 PM RND
Anonymous
Unregistered


I'm trying to assign a random number to a value, but the value that comes out is the same one every time. Can someone please explain the RND and SRND commands a little more in depth than the manual.

Here are the lines I've tried to get to work:

$X = Rnd() $user_tmp = "@userid" + ".$X"

Every time I try it, it comes back the same value. Even after I reboot, even from a different workstation (NT 4.0 sp3)

Top
#423 - 1999-09-13 09:34 AM Re: RND
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
The RND() function returns pseudo-random numbers. That is to say, a series of numbers that have no apparent relationship to one another. Calls to RND() will return the same series of numbers everytime, unless you set the "seed" value with SRND(), in which case you'll get a different series of the same numbers everytime.

I had the same problem over here. I wanted to create a kixtart script that ran under the scheduler to reboot all our NT workstations every night at 2:00 am. Not only that, I wanted to randomly set a shutdown delay timer so that all the workstations weren't making restart DHCP requests at the same time.

The solution was that instead of using the RND() function, I parsed the ip address of the workstation and used it in a calculation to derive a shutdown time delay unique to that workstation.

You could do something similar I imagine using the date,time or ip address as a "seed".

Shawn.

Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 1343 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.121 seconds in which 0.1 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org