Automating MikroTik RouterOS updates

Share your Config Push presets or discuss automation in general
User avatar
ementat
Posts: 8
Joined: Wed Jun 08, 2022 12:30 pm

Fri Jun 17, 2022 7:12 pm

I started using Unimus from version 2.2.2 one week ago and skipped 2.2.3 beta.
Use your mentality. Wake up to reality.
User avatar
Tomas
Posts: 1267
Joined: Sat Jun 25, 2016 12:33 pm

Mon Jul 25, 2022 1:48 pm

ementat wrote:
Fri Jun 17, 2022 7:12 pm
I started using Unimus from version 2.2.2 one week ago and skipped 2.2.3 beta.
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!
User avatar
ementat
Posts: 8
Joined: Wed Jun 08, 2022 12:30 pm

Tue Jul 26, 2022 7:41 am

Hi Tomas,

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]"
or

Code: Select all

:set RbVer "$[/system routerboard get current-firmware]"
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:

Code: Select all

:set PkgVer \"\$[/system package get routeros version]
I am expecting to get in Mikrotik script this:

Code: Select all

:set PkgVer "$[/system package get routeros version]"
, not this.

Code: Select all

:set PkgVer "7.4"
Use your mentality. Wake up to reality.
User avatar
Tomas
Posts: 1267
Joined: Sat Jun 25, 2016 12:33 pm

Tue Jul 26, 2022 6:07 pm

ementat wrote:
Tue Jul 26, 2022 7:41 am
Hi Tomas,

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]"
or

Code: Select all

:set RbVer "$[/system routerboard get current-firmware]"
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? ...
Anything in the $[...] format will need the $ escaped due to a "clash" with Unimus behavior modifier formatting:
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.
User avatar
ementat
Posts: 8
Joined: Wed Jun 08, 2022 12:30 pm

Wed Jul 27, 2022 4:29 am

Tomas wrote:
Tue Jul 26, 2022 6:07 pm
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]\"
Otherwise it will not work.

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]\"
we will get

Code: Select all

:set PkgVer "$[/system package get routeros version]"
Use your mentality. Wake up to reality.
Post Reply