Community discussions

MikroTik App
 
pafflootiy
just joined
Topic Author
Posts: 10
Joined: Tue Sep 23, 2014 10:27 am

such item (4)

Mon Dec 05, 2016 1:44 pm

I have 26k enteris in address-list. And with this code:
/ip firewall address-list remove number=[find list=redirect]
i randomly resieve "no such item (4)" error
This is 1st row of *.auto.rsc script. Next goes updated address-list.
 
patrick7
Member
Member
Posts: 341
Joined: Sat Jul 20, 2013 2:40 pm

Re: such item (4)

Mon Dec 05, 2016 1:51 pm

Try
/ip firewall address-list remove [find where list=redirect]
 
pafflootiy
just joined
Topic Author
Posts: 10
Joined: Tue Sep 23, 2014 10:27 am

Re: such item (4)

Mon Dec 05, 2016 1:56 pm

Try
/ip firewall address-list remove [find where list=redirect]
Thanks, i'll try. And will it work the same with:
/ip proxy access remove number=[find action=deny]
?
 
patrick7
Member
Member
Posts: 341
Joined: Sat Jul 20, 2013 2:40 pm

Re: such item (4)

Mon Dec 05, 2016 5:56 pm

Should be working if you change it like I mentioned above.
 
User avatar
mrz
MikroTik Support
MikroTik Support
Posts: 7042
Joined: Wed Feb 07, 2007 12:45 pm
Location: Latvia
Contact:

Re: such item (4)

Mon Dec 05, 2016 6:00 pm

Commands
/ip firewall address-list remove number=[find list=redirect]

and

/ip firewall address-list remove [find where list=redirect]

does exactly the same.
Error occurs in cases if command tries to remove an item that does not exist any more (dynamic entries that already was removed, other script or user manually is modifying address list at the same time when command is executed)
 
pafflootiy
just joined
Topic Author
Posts: 10
Joined: Tue Sep 23, 2014 10:27 am

Re: such item (4)

Tue Dec 06, 2016 10:57 am

Error occurs in cases if command tries to remove an item that does not exist any more (dynamic entries that already was removed, other script or user manually is modifying address list at the same time when command is executed)
Is there any solution?
 
User avatar
BlackVS
Member Candidate
Member Candidate
Posts: 172
Joined: Mon Feb 04, 2013 7:00 pm
Contact:

Re: such item (4)

Tue Dec 06, 2016 1:00 pm

Error occurs in cases if command tries to remove an item that does not exist any more (dynamic entries that already was removed, other script or user manually is modifying address list at the same time when command is executed)
Is there any solution?
Use foreach loop which enumerate results of [find list=redirect] and for each element call remove command using exception handling (:do/on-error).
 
pafflootiy
just joined
Topic Author
Posts: 10
Joined: Tue Sep 23, 2014 10:27 am

Re: such item (4)

Tue Dec 06, 2016 2:11 pm

Use foreach loop which enumerate results of [find list=redirect] and for each element call remove command using exception handling (:do/on-error).
Прошу простить мое невежество.
А это как?
Я про "луп". Т.е. делаю в скрипте несколько строк с одним тем же кодом (/ip firewall address-list remove number=[find list=redirect])?
Спасибо!
 
User avatar
mrz
MikroTik Support
MikroTik Support
Posts: 7042
Joined: Wed Feb 07, 2007 12:45 pm
Location: Latvia
Contact:

Re: such item (4)

Tue Dec 06, 2016 3:10 pm

/ip firewall address-list
:foreach i in=[find list=redirect] do={
  :do {
      remove $i;
  } on-error={ :put "xxx"};
 }
 
 
pafflootiy
just joined
Topic Author
Posts: 10
Joined: Tue Sep 23, 2014 10:27 am

Re: such item (4)

Tue Dec 06, 2016 3:48 pm

Please forgive my ignorance.
But what does mean "xxx" in:
  } on-error={ :put "xxx"};
 
Or should I leave it as is?
Thanks!
 
User avatar
mrz
MikroTik Support
MikroTik Support
Posts: 7042
Joined: Wed Feb 07, 2007 12:45 pm
Location: Latvia
Contact:

Re: such item (4)

Tue Dec 06, 2016 4:20 pm

That is the message printed on error,

http://wiki.mikrotik.com/wiki/Manual:Sc ... ime_errors
 
User avatar
BlackVS
Member Candidate
Member Candidate
Posts: 172
Joined: Mon Feb 04, 2013 7:00 pm
Contact:

Re: such item (4)

Tue Dec 06, 2016 6:21 pm

/ip firewall address-list
:foreach i in=[find list=redirect] do={
  :do {
      remove $i;
  } on-error={ :put "xxx"};
 }
 
Image
 
pafflootiy
just joined
Topic Author
Posts: 10
Joined: Tue Sep 23, 2014 10:27 am

Re: such item (4)

Wed Dec 07, 2016 9:30 am

That is the message printed on error
Thanks a lot! I'll try it.

Who is online

Users browsing this forum: No registered users and 28 guests