Community discussions

MikroTik App
 
Beelze
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 60
Joined: Tue Mar 04, 2014 12:21 pm

startup script

Mon May 19, 2014 3:53 pm

Following script runs at startup. Everything works, except the part where i resolve www.google.nl and where it should run the next script.
When i run it from the CLI, the whole script works.

Any suggestions?
#define global variables
       :global resolveThis "www.google.nl"
       :global test
       :global serverfile test.conf
       :global importfile import.conf
       
       #create configscript
       /system script add name=import-conf source="
           /tool fetch \\
               address=test.com \\ 
               src-path=$serverfile \\
               user=admin \\
               mode=https \\
               password=pass! \\ 
               dst-path=$importfile \\
               port=443 keep-result=yes \n
           /system script add name=$importfile source=[/file get $importfile contents]
           /system script run $importfile \n
       "
       
       #connect to the internet, then run script
       :local continue true
       
       while ($continue) do={
       [/ip dns cache flush]
           
           :set test [:resolve $resolveThis]
           
           :if ($test != "") do={
               /system script run import-conf
               :set continue false
           }
       }
 
Beelze
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 60
Joined: Tue Mar 04, 2014 12:21 pm

Re: startup script

Mon May 19, 2014 4:41 pm

It seems like the while loop is ignored and the statements in that scope aren't executed when I schedule the script at startup.
 
Beelze
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 60
Joined: Tue Mar 04, 2014 12:21 pm

Re: startup script

Mon May 19, 2014 5:27 pm

I think I found the problem. I defined the continue variable as :local instead of :global.

Who is online

Users browsing this forum: No registered users and 15 guests