Community discussions

MikroTik App
 
WirelessRudy
Forum Guru
Forum Guru
Topic Author
Posts: 3119
Joined: Tue Aug 08, 2006 5:54 pm
Location: Spain

syntax error in v.6.1

Fri Jun 21, 2013 12:19 pm

Why is this part of a script no more working in v6.1?
:if ($resolvedIP != $currentIP) do={
I get a syntax error with the "r" in $resolvedIP
highlighted where this always worked in v.5.x

Why is this and how to correct it?

(I hate it when we see major changes in ROS the scripting also changed. How can you ever implement scripting on a wide scale base if they have to be re-written each time you run an ROS update.... very bad.... :( )
 
User avatar
mrz
MikroTik Support
MikroTik Support
Posts: 7054
Joined: Wed Feb 07, 2007 12:45 pm
Location: Latvia
Contact:

Re: syntax error in v.6.1

Fri Jun 21, 2013 12:22 pm

There are no syntax changes in v6.1

You get error because resolvedIP is not defined. Same error you would have in v5.
 
WirelessRudy
Forum Guru
Forum Guru
Topic Author
Posts: 3119
Joined: Tue Aug 08, 2006 5:54 pm
Location: Spain

Re: syntax error in v.6.1

Fri Jun 21, 2013 12:46 pm

:local resolvedIP [:resolve "www.speedtest.net"];
:local currentIP [/ip firewall address-list get [find comment="speedtest_net"] address];
:if ($resolvedIP != $currentIP) do={
/ip firewall address-list set [find comment="speedtest_net"] address=$resolvedIP;
/log info "speedtest.net ip updated";
}
This is the full script.
It doesn't produce an error in 5.24. But it does in 6.1?

But when I put this same script in 5.24 terminal it DOES produce an error! So how do I now know if a script is working or not?

And if it is not, what is wrong with it? I made it in the early days of 5.x series and had it tested and it works fine. I had it implemented in 400+ units so now it maybe it doesn't even work and I'm not getting any error message of it failing too! pfff
 
User avatar
mrz
MikroTik Support
MikroTik Support
Posts: 7054
Joined: Wed Feb 07, 2007 12:45 pm
Location: Latvia
Contact:

Re: syntax error in v.6.1

Fri Jun 21, 2013 1:05 pm

When you paste script in terminal each line is treated as separate script, local variables are not seen from other scripts, so you get an error.

Put script in braces {} and then paste it in terminal. Will work on both v5 and v6.
 
WirelessRudy
Forum Guru
Forum Guru
Topic Author
Posts: 3119
Joined: Tue Aug 08, 2006 5:54 pm
Location: Spain

Re: syntax error in v.6.1

Fri Jun 21, 2013 1:34 pm

The script is performed in terminal (I think, it doesn't produce any errors) but when the same script is performed in the script (I 'run' the script) it get "script error: no such item" in the log....

So now it runs in the terminal I have no clue why it is not working in the script section of winbox?
So what to do next?

Script copied and paste from terminal:
/system script
add name=resolve_speedtest.net policy=ftp,reboot,read,write,policy,test,winbox,password,sniff,sensitive,api source=":local resolvedIP [:resolve \"www.speedt\
est.net\"];\r\
\n:local currentIP [/ip firewall address-list get [find comment=\"speedtest_net\"] address];\r\
\n:if (\$resolvedIP != \$currentIP) do={\r\
\n/ip firewall address-list set [find comment=\"speedtest_net\"] address=\$resolvedIP;\r\
\n/log info \"speedtest.net ip updated\";\r\
\n}\r\
\n\r\
\n"
 
telepro
Frequent Visitor
Frequent Visitor
Posts: 69
Joined: Sun Apr 03, 2011 7:50 pm

Re: syntax error in v.6.1

Tue Jun 25, 2013 1:24 am

i believe this is a problem introduced in 6.1, and was not present in 6.0.
See http://forum.mikrotik.com/viewtopic.php?f=1&t=73772 and
http://forum.mikrotik.com/viewtopic.php ... 3&start=74
for other reports regarding the same issue.

so far i have not heard from Mikrotik whether this is an error that was inadvertently introduced in 6.1, or whether this is a change in scripting requirements. I am hoping that Mikrotik will respond so we can either wait for a fix in 6.2 or else will need to edit / rewrite scripts.

Perhaps someone from Mikrotik will provide direction?????

Who is online

Users browsing this forum: No registered users and 26 guests