Community discussions

MikroTik App
 
mikrotik2014
just joined
Topic Author
Posts: 7
Joined: Wed Aug 07, 2013 9:23 am

script error: no such item (4)

Thu Jun 03, 2021 8:21 pm

why error in log: script error: no such item (4)
https://pasteboard.co/K4Vqitv.jpg

my script:
:foreach i in=[/ip dns cache find name~"youtube"] do={ :do { /ip firewall address-list add list=YouTube address=[/ip dns cache get $i address]; } on-error={} }
:foreach i in=[/ip dns cache find name~"youtube"] do={ :do { /ip firewall address-list add list=YouTube address=[/ip dns cache get $i name]; } on-error={} }
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 11982
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: script error: no such item (4)

Thu Jun 03, 2021 8:25 pm

why try to obtain on second foreach?
the address is already on list and if you try to add both. the second when resolved give an error because resolved IP already exist and the script stop

/ip firewall address-list
:foreach i in=[/ip dns cache find where name~"youtube"] do={
 :local xaddress [/ip dns cache get $i address]
 :if ([:len [find where address=$xaddress]] < 1) do={
  add list=YouTube address=$xaddress comment=[/ip dns cache get $i name]
 }
}

If you want a full address list used by youtube, instead everytime use scripts:
https://bgp.he.net/AS36040#_prefixes

Who is online

Users browsing this forum: alexantao and 25 guests