Community discussions

MikroTik App
 
tomascribb
just joined
Topic Author
Posts: 3
Joined: Wed Jul 14, 2010 4:58 pm

Script problem

Wed Jul 14, 2010 5:16 pm

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.
 
User avatar
omega-00
Forum Guru
Forum Guru
Posts: 1167
Joined: Sat Jun 06, 2009 4:54 am
Location: Australia
Contact:

Re: Script problem

Tue Jul 20, 2010 7:36 pm

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.
 
mehran
just joined
Posts: 18
Joined: Sat May 01, 2010 10:18 am

Re: Script problem

Thu Aug 26, 2010 2:09 pm

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

also try /ping instead of ping

Who is online

Users browsing this forum: Bing [Bot], vasilaos and 76 guests