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
ohara
2
:local c "Rulecomm"
/ip firewall mangle enable [find comment=$c];
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";
};
is wrong, what are you doing?
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.
ohara
6
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];
}
Do you know how I would structure the above using the API