Community discussions

 
TrueFriend
just joined
Topic Author
Posts: 7
Joined: Thu Nov 06, 2008 7:18 pm

Script variable in find comment rule

Tue Jun 26, 2012 10:49 pm

Please why does not this script?

Problem - This script enable all rules in mangle list.
:local comment "Rulecomm"
/ip firewall mangle enable [find comment=$comment];
This enable only one rule Rulecomm - ok
:local comment "Rulecomm"
/ip firewall mangle enable [find comment=Rulecomm];
I need to use a variable
 
User avatar
ohara
Member
Member
Posts: 369
Joined: Mon Jun 13, 2011 11:30 pm
Location: Warsaw

Re: Script variable in find comment rule

Wed Jun 27, 2012 12:01 am

:local c "Rulecomm"
/ip firewall mangle enable [find comment=$c];
 
TrueFriend
just joined
Topic Author
Posts: 7
Joined: Thu Nov 06, 2008 7:18 pm

Re: Script variable in find comment rule

Wed Jun 27, 2012 3:10 am

When I use it so if it does not work.
:local c "Rulecomm"
:local i [/ip firewall mangle enable [find comment=$c]];
:if (i=true) do={
:log warning "true";
} else={
:log warning "false";
};
 
User avatar
c0d3rSh3ll
Long time Member
Long time Member
Posts: 558
Joined: Mon Jul 25, 2011 9:42 pm
Location: [admin@Chile] >

Re: Script variable in find comment rule

Wed Jun 27, 2012 4:05 am

is wrong, what are you doing?
nothing
 
TrueFriend
just joined
Topic Author
Posts: 7
Joined: Thu Nov 06, 2008 7:18 pm

Re: Script variable in find comment rule

Wed Jun 27, 2012 1:33 pm

I want to make a script using variables that I find rule by comments and check it is enabled or disabled.
I have:
:local comment_name "LAN_Proxy";
:local i [/ip firewall nat get value-name=disabled number=[find comment=[$comment_name]]];
:if (i=true) do={
/ip firewall nat enable [find comment=[$comment_name]];
}

:local comment_name "From_internal";
:local i [/ip firewall mangle get value-name=disabled number=[find comment=[$comment_name]]];
:if (i=true) do={
/ip firewall mangle enable [/ip firewall mangle find];
}

:local comment_name "All_traffic";
:local i [/queue tree get value-name=disabled number=[find comment=[$comment_name]]];
:if (i=true) do={
/queue tree enable [find comment=[$comment_name]];
}
but does not work. I do not know what wrong.

This code is works:
:local i [/ip firewall nat get value-name=disabled number=[find comment=LAN_Proxy]];
:if (i=true) do={
/ip firewall nat enable [find comment=LAN_Proxy];
}

:local i [/ip firewall mangle get value-name=disabled number=[find comment=From_internal]];
:if (i=true) do={
/ip firewall mangle enable [/ip firewall mangle find];
}

:local i [/queue tree get value-name=disabled number=[find comment=All_traffic]];
:if (i=true) do={
/queue tree enable [find comment=All_traffic];
}
Sorry for my bad english.
 
User avatar
ohara
Member
Member
Posts: 369
Joined: Mon Jun 13, 2011 11:30 pm
Location: Warsaw

Re: Script variable in find comment rule

Wed Jun 27, 2012 8:15 pm

Try this; do not use system reserved names for variables and do not include underscore sign "_"
:local commentName "From_internal";
:local i [/ip firewall mangle get value-name=disabled number=[find comment=$commentName]];
:if (i=true) do={
/ip firewall mangle enable [/ip firewall mangle find comment=$commentName];
}
 
robpearmain
just joined
Posts: 2
Joined: Thu Nov 06, 2014 2:56 pm

Re: Script variable in find comment rule

Thu Nov 06, 2014 3:15 pm

Do you know how I would structure the above using the API
 
maiacpd
just joined
Posts: 2
Joined: Mon Jul 11, 2016 7:10 pm

Re: Script variable in find comment rule

Mon Aug 05, 2019 5:55 pm

:local c "Rulecomm"
/ip firewall mangle enable [find comment=$c];
Thank you!!!!

Who is online

Users browsing this forum: No registered users and 5 guests