/system ssh-exec address=192.168.1.2 user=admin command=“:global x "$y"”]
For the first time I see that additional quotation marks and their escaping are needed here … Where is it written in the description of the Ros syntax ?
no matter the syntax, it’s common sense for programming…
if “command” is a string, and is resolved by adding the value of “y”, how does it become?
“:global x mather father”
and obviously is one error, because you omit the " ".
no matter the syntax, it’s common sense for programming…
if “command” is a string, and is resolved by adding the value of “y”, how does it become?
“:global x mather father”
and obviously is one error, because you omit the " ".
To be honest, I didn’t really understand. I’m not making a string out of individual variables. In my example, the string is single and it is up to the parser to pass it correctly.
:local y [/system identity get name]
[/system ssh-exec address=192.168.1.2 user=admin command=":global x $y"]
everything works correctly, and if I do:
:local y [/system routerboard get model]
[/system ssh-exec address=192.168.1.2 user=admin command=":global x $y"]
[/system ssh-exec address=192.168.1.2 user=admin command=":global x \"[/system routerboard get model]\""]
Rex, I understand what you want to say, but to enclose the construction in additional quotes here …, it seems to me that the Ros parser could be smarter…
The other device do not have on memory any variable, the command is just a simple string passed to the other device.
I thought that the string is passed exactly as a command. In the sense that after transmission, it is analyzed by the language of the server device. Therefore, I would like to write:
[/system ssh-exec address=192.168.1.2 user=admin command=“:global x [/system routerboard get model]”]
But since quotes and escaping are needed, so be it, the main thing is that it works.
You’re right, it should give error immediately when typing
:local strvar thisisonestring
without the proper quotes…
instead of accepting it anyway just because there is no space (or other reserver characters) in between.
Instead in the case of “command” it does exactly what has been ordered,
it is not creating executable code, but only a line of text, it rightly ignore what is written inside.
If he put in quotes without being asked, you know what a pain in the ass if you have to do other things…
By the way the command of the topic discussed today, can work like this too, easier, shorter.
[/system ssh-exec address=192.168.1.2 user=admin command=":global x [/system routerboard get model]"]
# for:
[/system ssh-exec 192.168.1.2 ":global x [/system routerboard get model]"]
# "user=admin" I understand that it can be omitted because the server and client router have the same user.
Is it possible to work around this problem and pass the contents of the function not as a string, but as code?
Or did the developers of Microtik specifically block this possibility ?