I'm trying to disable/enable an IP address via a script but ignore it if the IP address is already in the correct state.
However, I'm getting an issue if I nest the If statements.
Code: Select all
if ([/ping 172.16.1.1 interface=ether2 interval=1 count=3] = 0) do={
:if ([ /ip address get [find address="172.16.2.2/32"] disabled]) do={
/ip address enable [find address="172.16.2.2/32"]
}
} else={
:if ([/ip address get [find address="172.16.2.2/32"] enabled]) do={
/ip address disable [find address="172.16.2.2/32"]
}
}
So I broke it down a little and these 2 scripts work OK.input does not match any value of value-name
This tests the address enable/disable
Code: Select all
if ([/ping 172.16.1.1 interface=ether2 interval=1 count=3] = 0) do={
/ip address enable [find address="172.16.2.2/32"]
} else={
/ip address disable [find address="172.16.2.2/32"]
}
Code: Select all
:if ([/ip address get [find address="172.16.2.2/32"] disabled]=true) do={
:put "The address is disabled!";
} else={
:put "The address is enabled!";
}
Would appreciate any pointers in the right direction.
Thanks