How to redirect echo output over ssh to file
I am trying to redirect the contents of a variable to a file via ssh. as:
ssh $MachineIP echo $CM_Config > $mName/CM_CONFIG
where $CM_Config
is a local variable in my host containing multiple lines and $mName/CM_CONFIG
is in $MachineIP
how to redirect local variable to remote file if my ssh configurations are correct. thanks in advance
+3
source to share
2 answers
In my case, the problem is solved with this command:
ssh $MachineIP " echo \"$CM_Config\" > \"$mName/CM_CONFIG\" "
In fact, without including my variable, my problem was not solved. Perhaps this is because the contents of these variables are somehow similar to a bash command and are on multiple lines.
+3
source to share