Hi guys, i am trying to learn funcion for simplify some of my autoprovisioning script, having some trouble for remote ssh output interpretation.
This is an example:
/foreach aDev in=[/ppp secret find comment=“Autoprovisioning”] do={
#Funcion
:global aIP [/ppp secret get $aDev “remote-address”]
:global upload do={:global aIP; /tool fetch upload=yes user=temp src-path=$upFile url=“sftp://$aIP/$upFile”}
#This seems to be working well:
$upload upFile=“autoprov.auto.rsc”
#I need a funcion can subsituite all verbose command to a simply command for grab some info on a remote machine… something like:
$aGet aRead=“/system script enviroment get autoprovstatus value”
And if $aGet value is “OK” do={some stuff}
For now i have try this:
:global aGet do={
:global aRead
:global aIP
([/system ssh-exec address=$aIP user=admin-ssh command=$aRead as-value]->“output”)
}
#This comment below gave me error syntax
$aGet aRead=“:put [/system script environment get autoprovstatus "value"]”
}
I think my method is wrong i dont understand very well how to do this, can you help me with some example?
I need to have a way for verify if a remote host has or not for example existence of user “temp”.
After many attempt with the command ssh-exec i seen that when i use his output as variable there is a value and 2 square characters, seems to grab value with newline characters and there is another problem, maybe someone know some other way more logical to do this.
Thanks