SSH command output can be saved with "output-to-file" option.
1) true, thanks (meanwhile I had found it out too)
2) but there is another quirk: the file content is not immediately available, you need to insert a delay between creating the file and reading it (sic):
:global GoldenUser; :global GoldenIP;
:local filename outfile
:local myMac E4:8D:8C:26:DC:03
#:local myMac 04:F0:21:1D:77:70
do {
/file remove out
} on-error={
:put "file already deleted"
}
do {
/system ssh user=$GoldenUser $GoldenIP ":put [/interface wireless registration-table get [ find mac-address=$myMac ] signal-strength ]" output-to-file=$filename
} on-error={
:put "ERR"
}
:delay 1
:local result
:set result [ /file get [ find name=$filename ] contents ]
:put "res:$result:$filename"
(without :delay the script fails!)
3) this script runs fine from the console, but not if launched remotely via SSH:
from console:
[root@router] /system script> run test
file already deleted
Welcome back!
res:-85dBm@6Mbps
:outfile
launching from SSH, the outbound ssh connection seems to fail (out file is not created)
$ ssh root@ROUTER_IP "/system script run test"
root@ROUTER_IP's password:
file already deleted
ERR
res:-85dBm@6Mbps
:outfile
any hint on why this happens/how to fix it?
5) also if I run the script trough :execute it fails to connect via ssh
[root@router] /system script> {:local a [/system script get test source]; :execute script=$a file=OutputOfScript}
[root@router] /system script> :put [ /file get OutputOfScript.txt contents ]
file already deleted
ERR
no such item
it seems that there is something really hard about using outbound SSH in a script, or possibly this could be the result of some security measure