Hello. I want to use in routes Active flag for building logic.
Example:
:if ([ip route get [find gateway=8.8.4.4 and static and active]])=true :do …
This command is active if a route it back, but if not then returns No such item.
How to do this the true or false?
Try:
:if ([:len [ip route find gateway=8.8.4.4 and static and active]] > 0) do={
#code here
}
:local getState [/ip route get value-name=active [/ip route find where gateway=8.8.4.4 and static=yes]]
:if ($getState = true) do {
SCRIPT WHEN ROUTE IS PRESENT AND ACTIVE
}
:if ($getState = false) do {
SCRIPT WHEN ROUTE IS PRESENT BUT NOT ACTIVE
}
:if ($getState = "nothing") do {
SCRIPT WHEN THERE IS NO ROUTE
}