I have this below script.
If it matters, it updates value of ip address from the hostname mentioned in the comment.
The problem is, this loop breaks if it reaches an inexistent host name "failure: dns name does not exist"
How can I suppress that error so that it continues in case of error ?
I tried adding on-error={}; (it is near the end of the script), but I am getting "expected end of command" when adding that.
Maybe I just don't understand the format of the if / do in these scripts.
If it matters, it updates value of ip address from the hostname mentioned in the comment.
The problem is, this loop breaks if it reaches an inexistent host name "failure: dns name does not exist"
How can I suppress that error so that it continues in case of error ?
I tried adding on-error={}; (it is near the end of the script), but I am getting "expected end of command" when adding that.
Maybe I just don't understand the format of the if / do in these scripts.
Code:
# define variables:local list:local comment:local newip:local oldip# Loop through each entry in the address list.:foreach i in=[/ip firewall address-list find] do={ # Get the first five characters of the list name #:set list [:pick [/ip firewall address-list get $i list] 0 5] :set list [/ip firewall address-list get $i list] # If they're 'adr_ip_', then we've got a match - process it :if ($list = "adr_ip_list") do={ # Get the comment for this address list item (this is the host name to use) :set comment [/ip firewall address-list get $i comment] :set oldip [/ip firewall address-list get $i address] # Resolve it and set the address list entry accordingly. : if ($newip != $oldip) do={ :set newip [:resolve $comment] /ip firewall address-list set $i address=$newip } # if I enable this here, I get error "expected end of command" <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< HERE <<<<<<<<<<<< # on-error={}; :put $comment; :put $newip; }}
Statistics: Posted by adrianTNT — Sun Feb 04, 2024 6:30 am