Community discussions

MikroTik App
 
rodolfo
Long time Member
Long time Member
Topic Author
Posts: 553
Joined: Sat Jul 05, 2008 11:50 am

error using on-error

Tue Nov 22, 2016 11:21 pm

Hi.
I try to delete pppoe connections do not having a simple queue.
I use this code:
:foreach Id in=[/ppp active find] do={
:local Iface [/ppp active get $Id name]
:put $Iface
:if ([/queue simple find name=("<pppoe-".$Iface.">")]="") do={
/ppp active remove $Iface} }

The problem is this script interrupts every time with error "no such item"

I tried to use on-error in many positions:
:foreach Id in=[/ppp active find] do={
:local Iface [/ppp active get $Id name]
:put $Iface
:if ([/queue simple find name=("<pppoe-".$Iface.">")]="") do={
/ppp active remove $Iface} } on-error{}

but each time the error is "expected end of command"

How can I do?

Thanks
Rodolfo.
 
User avatar
BlackVS
Member Candidate
Member Candidate
Posts: 172
Joined: Mon Feb 04, 2013 7:00 pm
Contact:

Re: error using on-error

Wed Nov 23, 2016 7:40 am

Hi.
I try to delete pppoe connections do not having a simple queue.
I use this code:
...
/ppp active remove $Iface
...
remove requires the number or id of object to be deleted if I remember right.
I.e. try run this
/ppp active remove $Id
but each time the error is "expected end of command"
Wrong usage of on-error - it requres separate :do statement:
:do { command which may produce error } on-error={code on error}
Not "do" from "foreach" or "if".

Who is online

Users browsing this forum: flapviv and 23 guests