I need help to test for routerOS version. Since 7.10xxx user the new time format, how do I test for 7.10 or newer.
7.8 no
6.49 no
7.1 no
7.10beta5 yes
7.10rc1 yes
7.24 yes
8.1beta22 ok
Tried to extract the routerOS version, but not sure how to make a regex true that will work on all version.
It has been simpler if 7.1 was named 7.01
tonum does not work with decimal.
This just removes the first dot [
:local ver [/system resource get version]
:local dot [:find $ver “.”]
:local new “$[:pick $ver 0 $dot]$[:pic $ver ($dot + 1) 99]”
:put $new
]
This gives 710beta5 (development)
I can remove beta5… using a for each loop, but still how to test against 710 and not get error with 71 (fail) vs 711 (ok)
There mest be a simpler way to do this?
> :put [$version2arr “7.10beta5 (development) 2023-05-03 14:33:19”]
7;10beta5;;development;2023-05-03 14:33:19
About development versions, the minor version is 10beta5, but some subsequents division is possible, but for me is excessive.
(the date of 10 beta 5 build time is approx, I do not rememmber the correct value)
If you want convert the version to a number, just for compare two numbers, you can do two things:
Convert build date to Unix Epoch, like
7.7 (stable) Jan/12/2023 07:35:45 ==>> 1673508945 (GMT)
7.10beta5 (development) 2023-05-09 13:38:22 ==>> 1683639502 (GMT)
datetime2epoch is here >> http://forum.mikrotik.com/t/i-did-it-script-to-compute-unix-time/68576/24
{
:local a [$datetime2epoch [/system resource get build-time]] ; # read current RouterOBARD value
:local b [$datetime2epoch “Dec/03/2021 12:15:05”] ; # from RouterOS 6.48.6
:local c [$datetime2epoch “2023-05-09 13:38:22”] ; # from RouterOS 7.10beta5
:put ($a > $b)
:put ($b < $c)
:put ($a < $c)
}
And spitting again the patch value only if is present “alpha”, “beta”, or “rc”:
2h)
convert the vesion based on numbers, like what @eworm do:
7.7 stable (is implicit 7.7.0 stable 0) ==>> 7 * 0x10000000 + 7 * 0x100000 + 0 * 0x1000 + “stable = 0x300” + 0 = 0x070700300 (on decimal is 1886388992)
7.10beta5 development (is implicit 7.10.0 beta 5) ==>> 7 * 0x10000000 + 10 * 0x100000 + 0 * 0x1000 + “beta = 0x200” + 5 = 0x071000205 (on decimal is 1895825925)
2d)
or convert it to decimals (is more readable than hex…)
7.7 stable (is implicit 7.7.0 stable 0) ==>> 7 * 10000000 + 7 * 100000 + 0 * 1000 + “stable = 300” + 0 = 70700300 (on hex is 0x436CD0C)
7.10beta5 development (is implicit 7.10.0 beta 5) ==>> 7 * 10000000 + 10 * 100000 + 0 * 1000 + “beta = 200” + 5 = 71000205 (on hex is 0x43B608D)