Send SMS from different router

Bug??? Or syntax error…

/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 " ".

Yes, since REX wrote it, it works that way.

yurself wite this:

:local y “mather father”;

why you use quotation marks?

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.

The other device do not have on memory any variable, the command is just a simple string passed to the other device.

: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…

This:

[/system ssh-exec address=192.168.1.2 user=admin command=":global x [/system routerboard get model]"]

create inside remote device the variable x with inside it’s own routerboard model



This:

[/system ssh-exec address=192.168.1.2 user=admin command=":global x \"$[/system routerboard get model]\""]

create inside remote device the variable x with inside the local/calling routerboard model
(notice the added $ inside, not only the quotes)

“$” I accidentally missed

Please avoid this attitude…
I know the documentation is poor
and what I know comes from my own experience.

??? NO…


I don’t understand what you mean, honestly…

Please avoid this attitude…
I know the documentation is poor
and what I know comes from my own experience.

Thank you very much! It’s good that there are experienced friends.

You’re making fun of me

??? NO…

your example is too exaggerated.

I don’t understand what you mean, honestly…

Probably it’s all from the problems of automatic translation

Yes… I understand… :wink:

Thanks again for the “lesson with quotes”

We all have learned… Rex is a great programmer.

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.

BR.

My question then is it possible to transfer a ready - made function to another device and execute it there ?
Something like that:


:global myFunc do={:log warning test}
[/system ssh-exec address=192.168.1.2 user=admin command=":global myFunc \"$myFunc\"; [$myFunc]"]

A global variable on the remote router is created and

/system script environment shows $myFunc
(code), but

:put [:typeof $myFunc]
str

The option with :parse does not help either:

:global myFunc [:parse "log warning test"]
[/system ssh-exec address=192.168.1.2 user=admin command=":global myFunc \"$myFunc\"; [$myFunc]"]

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 ?

I don’t know, you’ll have to try it out.