Automating MikroTik RouterOS updates
We just released 2.2.4, which should contain the final fix for these variable prefixing issues. Please let us know if all your Tik scripts work properly now without needing to be escaped with "\".
Thanks!
Hi Tomas,
On version 2.2.4 I don't need to double-escape all "$", but when I am using something like this:
or
I need to double-escape "$" or the code inside [] will be executed during the config push and I am getting the expression result in script code, not the expression itself. I don't think this is the expected behavior, right? To clarify a little bit more:
When I am using in config push preset this expression: I am expecting to get in Mikrotik script this: , not this.
On version 2.2.4 I don't need to double-escape all "$", but when I am using something like this:
Code: Select all
:set PkgVer "$[/system package get routeros version]"
Code: Select all
:set RbVer "$[/system routerboard get current-firmware]"
When I am using in config push preset this expression:
Code: Select all
:set PkgVer \"\$[/system package get routeros version]
Code: Select all
:set PkgVer "$[/system package get routeros version]"
Code: Select all
:set PkgVer "7.4"
Use your mentality. Wake up to reality.
Anything in the $[...] format will need the $ escaped due to a "clash" with Unimus behavior modifier formatting:ementat wrote: ↑Tue Jul 26, 2022 7:41 amHi Tomas,
On version 2.2.4 I don't need to double-escape all "$", but when I am using something like this:
orCode: Select all
:set PkgVer "$[/system package get routeros version]"
I need to double-escape "$" or the code inside [] will be executed during the config push and I am getting the expression result in script code, not the expression itself. I don't think this is the expected behavior, right? ...Code: Select all
:set RbVer "$[/system routerboard get current-firmware]"
https://wiki.unimus.net/display/UNPUB/Mass+Config+Push
Same goes for variables, if you needed to use ${...} and send that directly to the device without the variable being substituted, you would need to escape the $ as per https://wiki.unimus.net/display/UNPUB/Device+Variables
The issue previously was that any $ would need escaping, which was incorrect. But having to escape RouterOS script syntax sequences which class with the Unimus syntax is correct. No way to avoid that - sorry.
Thanks for linking Unimus wiki. I just want to clarify for myself: both wiki examples are escaping $. I got the idea about control sequence and variables. But in my example i need to DOUBLE escape $ like this:
Code: Select all
:set PkgVer \"\\$[/system package get routeros version]\"
I don't see wiki examples with DOUBLE escaping in provided articles. So, my question is - is $ DOUBLE escaping in his situation an expected behavior? According to the wiki from this
Code: Select all
:set PkgVer \"\$[/system package get routeros version]\"
Code: Select all
:set PkgVer "$[/system package get routeros version]"
Use your mentality. Wake up to reality.