Community discussions

MikroTik App
 
WirelessRudy
Forum Guru
Forum Guru
Topic Author
Posts: 3119
Joined: Tue Aug 08, 2006 5:54 pm
Location: Spain

time server resolving script, help please!

Thu Oct 11, 2012 12:58 pm

I made the following script:
/system script add name=resolve_time.windows.com policy=ftp,reboot,read,write,policy,test,winbox,password,sniff,sensitive,api source=":local resolvedIP [:resolve time.windows.com]; :local currentIP [/ip firewall address-list get [find comment=time.windows.com] address]; :if (resolvedIP != currentIP) do={/ip firewall address-list set [find comment=time.windows.com] address=resolvedIP; /log info ip time.windows.com updated;}"
The script shows as being valid and can be executed manually.
And although a ping command does resolve the url into an ip address, this script won't do it.
I made an address list listing with IP address=1.2.3.4 for the given time server listing but nothing happens...... :(

Anybody that can shine his light on this?
 
User avatar
c0d3rSh3ll
Long time Member
Long time Member
Posts: 557
Joined: Mon Jul 25, 2011 9:42 pm
Location: [admin@Chile] >

Re: time server resolving script, help please!

Thu Oct 11, 2012 5:26 pm

{
:local resolvedIP [:resolve time.windows.com]
:local currentIP [/ip firewall address-list get [find comment=time.windows.com] address]
:if ($resolvedIP != $currentIP) do={/ip firewall address-list set [find comment=time.windows.com] address=$resolvedIP 
/log info "ip time.windows.com updated"}
}
 
psamsig
Member Candidate
Member Candidate
Posts: 161
Joined: Sun Dec 06, 2009 1:36 pm
Location: Denmark

Re: time server resolving script, help please!

Sat Oct 13, 2012 2:51 pm

In other words, you missed the $ in front of the variables.

But since we are in the process of rewriting the original, here is how I would have put it:
/ip firewall address-list {
    :local resolvedIP [:resolve time.windows.com]
    :local o [find comment=time.windows.com]
    :if ($resolvedIP != [get $o address]) do={
        set $o address=$resolvedIP 
        /log info "ip time.windows.com updated"
    }
}
in this case it's mainly a matter of taste of style though.

Who is online

Users browsing this forum: No registered users and 49 guests