Community discussions

MikroTik App
 
oooscar
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 84
Joined: Sun Jan 05, 2014 12:56 pm
Location: Spain
Contact:

Script for all ROS versions

Fri Jul 18, 2014 11:16 pm

Hi,
on the 6.14 realse:

What's new in 6.14 (2014-Jun-06 15:34):

*) sntp - 'mode' now is a read-only property, it is set to broadcast if no
server ip address is specified;

How to do a script that Works with all OS versions.

I have a Script working with with <6.14:
/system ntp client
set unicast=yes enabled=yes primary-ntp=xxxx secondary-ntp=\
xxxx

For >=6.14 should be (other case script doen't load):
/system ntp client
set enabled=yes primary-ntp=xxxx secondary-ntp=\
xxxx

I need a script for all versions how to do it ....

Thank's
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 12008
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: Script for all ROS versions

Sat Jul 19, 2014 1:36 am

Can be used to check any version of routeros.

6.7 = numeric version 607
6.14 = numeric version 614
6.17 = numeric version 617

From 3.x no other "2 point" version like 2.9.27

This function obviously not count "rc" version and other.
:global ROSver value=[:tostr [/system resource get value-name=version]];
:global ROSverH value=[:pick $ROSver 0 ([:find $ROSver "." -1]) ];
:global ROSverL value=[:pick $ROSver ([:find $ROSver "." -1] + 1) [:len $ROSver] ];
:if ([:len $ROSverL] < 2) do={ set $ROSverL value=("0".$ROSverL) };

:global ROSverN value=[:tonum ($ROSverL.$ROSverL)];

/system ntp client set enabled=yes primary-ntp=1.1.1.1 secondary-ntp=2.2.2.2;

:if ($ROSverN < 614) do={
 /system ntp client set unicast=yes;
};
 
User avatar
payday
Member Candidate
Member Candidate
Posts: 233
Joined: Thu Aug 16, 2012 11:05 pm

Re: Script for all ROS versions

Sat Jul 19, 2014 8:49 pm

Shorter version:
/system ntp client set enabled=yes primary-ntp=XXXX secondary-ntp=XXXXX

:global unicastYes [:parse "/system ntp client set unicast=yes"]
:do {$unicastYes} on-error={}
If command set unicast=yes in last line generates an error we just ignore it and script will continue.

Explanation:
http://wiki.mikrotik.com/wiki/Manual:Sc ... ime_errors
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 12008
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: Script for all ROS versions

Sat Jul 19, 2014 9:37 pm

Shorter version:
/system ntp client set enabled=yes primary-ntp=XXXX secondary-ntp=XXXXX

:global unicastYes [:parse "/system ntp client set unicast=yes"]
:do {$unicastYes} on-error={}
If command set unicast=yes in last line generates an error we just ignore it and script will continue.

Explanation:
http://wiki.mikrotik.com/wiki/Manual:Sc ... ime_errors
Obviously my script want be one way for test on what routeros version the script is running.

If you want make one shorter version, do really:
/system ntp client set enabled=yes primary-ntp=1.1.1.1 secondary-ntp=2.2.2.2;
:do { [:parse "/system ntp client set unicast=yes"] } on-error={ };
But you must test first if is runner under routeros 6.2+ because the command is unsupported on previous routeros version.
 
User avatar
payday
Member Candidate
Member Candidate
Posts: 233
Joined: Thu Aug 16, 2012 11:05 pm

Re: Script for all ROS versions

Sun Jul 20, 2014 11:00 pm

If you want make one shorter version, do really:
Thanks for cooperation :). Now I think it is the shortest version possible. :)
But you must test first if is runner under routeros 6.2+ because the command is unsupported on previous routeros version.
RouterOS 6.2 was released one year ago. I guess it is safe to assume that nobody uses it anymore. :)
 
User avatar
boen_robot
Forum Guru
Forum Guru
Posts: 2400
Joined: Thu Aug 31, 2006 4:43 pm
Location: europe://Bulgaria/Plovdiv

Re: Script for all ROS versions

Sun Jul 20, 2014 11:08 pm

RouterOS 6.2 was released one year ago. I guess it is safe to assume that nobody uses it anymore. :)
Ehh... no. That's not how RouterOS upgrades tend to work.

First off, you have all routers with old licenses that aren't upgraded to 6.*, but are staying at 5.*. Then there's also people who don't upgrade even when they can, because 6.* has had (and some may argue still has) a bumpy start.

That said, people who have AT ALL started at the 6.* branch have probably already upgraded way past 6.2. I for one am at 6.9 currently, and will upgrade either when a version isn't immediately followed by posts saying "OMFG, [something] broke down with the upgrade!", or if there's a fix in there that I actually care enough about.


As long as you clarify in comments or whatever that the script requires 6.2 at minimum, I think everyone using it will be all right ;) .
 
User avatar
payday
Member Candidate
Member Candidate
Posts: 233
Joined: Thu Aug 16, 2012 11:05 pm

Re: Script for all ROS versions

Mon Jul 21, 2014 1:11 am

RouterOS 6.2 was released one year ago. I guess it is safe to assume that nobody uses it anymore. :)
As long as you clarify in comments or whatever that the script requires 6.2 at minimum, I think everyone using it will be all right ;) .
Now, we have it all clarified. ;)

Who is online

Users browsing this forum: pav5, pegaz28, sas2k, tgkmilo and 107 guests