Script problem

Hi, I’ve a spript problem. I copy the code below:


:global remotepri;
:global remotebak;
:local pri [ping $remotepri interval=200ms count=50];
:log info message=$remotepri;
:log info message=$pri;
:local bak [ping $remotebak interval=200ms count=50];
:log info message=$remotebak;
:log info message=$bak;
:if ( $pri > $bak ) do={
:log info message=“pri”
/ip route set [find comment=“pri”] disabled=yes
/ip route set [find comment=“bak”] disabled=no
} else={
:log info message=“bak”
/ip route set [find comment=“bak”] disabled=yes
/ip route set [find comment=“pri”] disabled=no
}


The problem is: The first time you run the script the value of local variable “pri” get the correct value but successive executions this variable does not get any value.
I hope you can help me.

You’re missing the leading $ before the variables.

Eg:

:global remotepri;
:global remotebak;
:local pri [ping $remotepri interval=200ms count=50];
:log info message=$remotepri;
:log info message=$pri;
:local bak [ping $remotebak interval=200ms count=50];
:log info message=$remotebak;
:log info message=$bak;
:if ( $pri > $bak ) do={
:log info message=$pri
/ip route set [find comment="$pri"] disabled=yes
/ip route set [find comment="$bak"] disabled=no
} else={
:log info message=$bak
/ip route set [find comment="$bak"] disabled=yes
/ip route set [find comment="$pri"] disabled=no
}

You probably don’t need the quotes around a lot of those either, only if you’re using values that might have spaces or others odd chars in them.

Where do you assign value for?
:global remotepri;
:global remotebak;

also try /ping instead of ping