How to grab via ssh a value

Hi guys.
I need a way to have a remote value on a local variable, i have ssh configured with public keys, no password required from machine1 to machine2

:global Status ([/system ssh-exec address=10.50.0.243 user=admin-ssh command=":put [/system identity get "name"]" as-value]->"output") ; /put $Status

And i obtain as value the name of the remote machine but it is not clean it seems to keep newline characters

system script environment print

NAME VALUE

0 Status Test\r\n

There is a way to obtain a clean value without special characters?

Use API instead of SSH.

Hi thanks for your answer.
Is possible to use API from a RouterOS machine to another Routeros machine?

You will have to code it in scripting language. I’m not sure that is even possible.
Normally it would be best to do such things from a separate device (e.g. Raspberry Pi or similar) where you can use existing API client libraries and many other software tools.