I have a similar problem, did I get it right, you cannot have on-error={} inside loops ?
I have this below code where I am trying to resolve name to IP inside a loop, and script breaks if domain name is invalid, if I add on-error it breaks with "expected end of command".
Is the only option to use on-error outside of a loop ?
I have this below code where I am trying to resolve name to IP inside a loop, and script breaks if domain name is invalid, if I add on-error it breaks with "expected end of command".
Is the only option to use on-error outside of a loop ?
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 — Mon Feb 05, 2024 10:50 pm