I’m running RouterOS 6.31 and all scripts fails to access the variables defined as global if the script runs from the scheduler. But if I run any script from the the CLI everything works fine.
I was using the No-Ip script ( http://wiki.mikrotik.com/wiki/Dynamic_DNS_Update_Script_for_No-IP_DNS ) in RouterOS version 6.2x and never see a problem until last update. After seen that the problem was the global variable used in it I made a small script to test the behavior of the variables and can’t find the problem.
The test script it’s simple, a bunch of put and log to debug it and the attributes are read,write and test (in CLI and from Scheduler).
The first run from the CLI it will print “Mismatch”, and further executions will print the content of “str1” and the word “Equal” as expected. But if I make it run form the scheduler the global variable str1 will always be empty. It looks like it’s destroy after each execution. I
Anyone having the same problem or I’m miss using the global variables?.
Create scheduler which has only script name in it.
Create global variable in CL “global test [/system resource get uptime]”
Create script where first line is only “global test” and then later use variable in script.
It works for me:
/system scheduler
add interval=10s name=test on-event=test policy=
ftp,reboot,read,write,policy,test,password,sniff,sensitive start-date=
sep/22/2015 start-time=12:02:37
Thank you strods for your answer. Your script works, and I use it as base for further testing. I have found that to read a global variable the script need to have the Policy “policy” without it it fail to get the variable (It have to be set on both, the script policies and in the scheduler policies).