Bonjour, I'm trying to do something in bash, here is the code :
var1=Hello
var2=I want a coffee
function func () {
var_temp="alias $1='$2'" #I need ='' in the result
echo $1
echo $2
echo $var_temp; }
sshpass -e ssh -q $USER@host "$(declare -f func);func" $var1 $var2
Result $1=Hello
Result $2=I
Result $var_temp=alias Hello='I'
How can I export more than one word in ssh ? Thank you in advance, #be understanding for my english xD
func? If you want to add something to a file, just construct the string locally and pipe it to something likessh $USER@host 'cat >> the_file'.ssh, get the local things fixed:var2=I want a coffeeneeds quotes or escapes to protect the spaces, and all variable references should be double-quoted (e.g.echo "$var_temp"instead of justecho $var_temp). shellcheck.net is good at pointing out missing double-quotes. As forssh, my answer here may help.printf "alias %s='%s'\n" "$var1" "$var2" | ssh ...