It’s been 5 days scratching my head this thing i have this short script that run perfectly in terminal but not in script
the problem is that the false value contain in the if statement in not process by the script.
i tried many variance all of them refuse the false statement, anyone have a clue? :local met value=“2”;
:local R2WIFI value=([/ip route get [find distance=3] gateway]);
:local met value=([/ip route get [find distance=3] distance]);
:put $R2WIFI;
:if ($met !=“3”) do={put $met;/ip route disable [find comment=WIFI]} else={/ip route enable [find comment=WIFI];/ip route set gateway=$R2WIFI [find comment=WIFI]};
i also tried global for declaration
this one is not executing the else part, if i reverse the true part with a negative not working either
if ([/ip route get [find distance=3] distance] =3 )
is always true if route with distance 3 exists.
Due to you check distance of route with distance 3 and compare to 3.
If no such route than “get” returns error “no such item” (due to “find” returns empty array, not nil, not false but always array) and script stoppped to run (i.e “else” not running but whole script stopped due to error…)
Question - what will you wish this script to do?
setting the gateway with local R2WIFI [[/ip route get [find distance=3] gateway]];
disabling the route with the route _commented WIF_I if no metric 3 is shown in route table
i know it’s not what i am doing right now with the else (it’s not working either)
i tried many combination
they are working in terminal but not in the script shell
1 find a metric 3
2 get the gateway associated with it
3 if metric3 = true enable and set a commented route with the gateway(2)
4 if metric3 = false disable the commented route