Community discussions

 
leon84
Member Candidate
Member Candidate
Topic Author
Posts: 172
Joined: Wed Dec 02, 2009 12:15 pm

How to write a script and do its debug

Fri Aug 02, 2019 10:17 am

Is there an external tool that help in script writing? When I use directly winbox I don't have any debug method. I must insert some log output to check for example variables content. If there is a syntax error the script doesn't run but I don't know where is the problem.

Thanks in advance
 
reiniss2
MikroTik Support
MikroTik Support
Posts: 54
Joined: Wed Jan 02, 2019 12:14 pm
Location: Latvia
Contact:

Re: How to write a script and do its debug

Fri Aug 02, 2019 11:53 am

Is there an external tool that help in script writing? When I use directly winbox I don't have any debug method. I must insert some log output to check for example variables content. If there is a syntax error the script doesn't run but I don't know where is the problem.

Thanks in advance
For debugging you are doing it correctly by using "output" commands in order to see if the variable contains the desired value.
Regarding syntax errors, you can edit scripts via CLI with "/system script edit MyScriptName value-name=source". Whenever you see text red, syntax is wrong. Press F5 to update the syntax check.
Otherwise, you can use "/system script print" and it will output the scripts with the syntax highlighter and the same rule applies -> red text has errors.
 
User avatar
Jotne
Forum Guru
Forum Guru
Posts: 1290
Joined: Sat Dec 24, 2016 11:17 am
Location: jo.overland at gmail.com

Re: How to write a script and do its debug

Fri Aug 02, 2019 12:28 pm

I do put the script in curly brackets {} and cut past it to the terminal.
This way it runs as you should run it from the script option.
Also I do use a lot of :put to see what is going on with the variables.
 
How to use Splunk to monitor your MikroTik Router

MikroTik->Splunk
 
 
leon84
Member Candidate
Member Candidate
Topic Author
Posts: 172
Joined: Wed Dec 02, 2009 12:15 pm

Re: How to write a script and do its debug

Fri Aug 02, 2019 12:38 pm

Thanks a lot!

Who is online

Users browsing this forum: No registered users and 7 guests