Community discussions

MikroTik App
leon84
Member Candidate
Member Candidate
Topic Author
Posts: 201
加入: 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
Top
Reinis
MikroTik Support
MikroTik Support
Posts: 82
加入: 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 F5to 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.
Top
用户头像
Jotne
Forum Guru
Forum Guru
Posts: 3221
加入: Sat Dec 24, 2016 11:17 am
Location:Magrathean

Re: How to write a script and do its debug

Fri Aug 02, 2019 12:28 pm

我把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:putto see what is going on with the variables.
Top
leon84
Member Candidate
Member Candidate
Topic Author
Posts: 201
加入: Wed Dec 02, 2009 12:15 pm

Re: How to write a script and do its debug

Fri Aug 02, 2019 12:38 pm

谢谢!
Top

Who is online

Users browsing this forum:controlcand 9 guests