Community discussions

MikroTik App
 
yogii
Member Candidate
Member Candidate
Topic Author
Posts: 148
Joined: Wed Jun 16, 2010 5:38 am
Location: Batam, Indonesia

can't disable rule using number from looping

Thu Nov 03, 2011 6:51 pm

hello, please help me.

I've tried to disable a lot of lines rule in /ip firewall mange using looping, but i got error message.
:for a from=0 to=4 do= {/ip fi mangle disable $a};
interrupted
           no such item
why i can't do it?

thanks...
 
changeip
Forum Guru
Forum Guru
Posts: 3830
Joined: Fri May 28, 2004 5:22 pm

Re: can't disable rule using number from looping

Thu Nov 03, 2011 7:26 pm

you have to print them first to assign them numbers. or you can use

/ip firewall mangle> print
....
/ip firewall mangle> set 11,12,13,14 disabled=yes
 
yogii
Member Candidate
Member Candidate
Topic Author
Posts: 148
Joined: Wed Jun 16, 2010 5:38 am
Location: Batam, Indonesia

Re: can't disable rule using number from looping

Sun Nov 06, 2011 2:08 pm

thank you for reply, but i still can't disable rule by looping number.
 
changeip
Forum Guru
Forum Guru
Posts: 3830
Joined: Fri May 28, 2004 5:22 pm

Re: can't disable rule using number from looping

Sun Nov 06, 2011 6:18 pm

The problem is that you have deleted an entry and that reorders things... try adding step=-1 to that loop so that you aren't changing the order of things as it goes along.

oh, you arent deleteing, just disabling.. try this:

/ip firewall mangle print
:for a from=0 to=4 do={
/ip fi mangle set $a disable=yes
};
 
fewi
Forum Guru
Forum Guru
Posts: 7717
Joined: Tue Aug 11, 2009 3:19 am

Re: can't disable rule using number from looping

Sun Nov 06, 2011 6:54 pm

It would be cleanest not to use numbers at all. The item numbers are for people. For scripts you should use find commands to return the items you're interested in, and then act on those. For example, set a comment of "thisOne" on items 0 through 4. Then you can use:
/ip firewall mangle { disable [find comment="thisOne"] };

Who is online

Users browsing this forum: No registered users and 66 guests