Page 1 of 1

time server resolving script, help please!

Posted: Thu Oct 11, 2012 12:58 pm
by WirelessRudy
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?

Re: time server resolving script, help please!

Posted: Thu Oct 11, 2012 5:26 pm
by c0d3rSh3ll
{
: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"}
}

Re: time server resolving script, help please!

Posted: Sat Oct 13, 2012 2:51 pm
by psamsig
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.