Generate random numbers

Hi all! (sorry for my bad english). I have a script:

{
/tool sniffer stop
local 1 [pick [sys clock get date ] 0 3]
local 2 [pick [sys clock get date ] 4 6]
loca 3 [pick [sys clock get date ] 7 12]
local time [/system clock get time]
local date "$2$1$3"
local status [/tool sniffer get running]
if ($status = false ) do={ put $time; put $date; tool sniffer set file-name="usb1/$date, 4" ; / tool sniffer start}
}

This script start packet sniffer and add system date to the name of file. In my router SNMP Client didn’t work because router is setting in bridge. That’s why i need add random number to the filename. How to create it? Thanks…

Have you seen this: http://forum.mikrotik.com/t/pseudo-random-number-generator-script-mersenne-twister/51962/1 ?

Thank you. But its very difficult for me. How can i make it easier? I know that in c++ the function name is rand().

Well, depends on how much “random” your number should be. As far as I kow, there is no ROS command for generation random numbers. Therefore you have to take some numbers and do some math operation with them in order to get random number.

If you would like to have one digit from 0-9 interval, I could imagine for example to summarize all digits from date+time + add some number that is really changing - e.g. actual number of connections (or even more such numbers) and take last digit of the sum. This could be easy and maybe close to random number.

It also depends on how many random numbers and how often you will need…

Take it as an idea that could help, nothing I have done already.

simple random number = cpu load :smiley: just multiple it to get required range :stuck_out_tongue:

example:

:delay ([/system resource get cpu-load ] *8)

Nice hint, but on my powerful machineis everityme is between 2 and 3 …

I write my own version:

Random number between 0 and 99 or string between 00 and 99
http://forum.mikrotik.com/t/random-number-between-0-and-99-or-string-between-00-and-99/149267/1