2

I want to send variable from source to host, and exec host script. Here is my code :

var1=1 ssh -p 42 root@xxx /bin/bash << EOF var2=2 echo $var1 echo $var2 EOF 

Return : 1

var1=1 ssh -p 42 root@xxx /bin/bash << \EOF var2=2 echo $var1 echo $var2 EOF 

Return : 2

How to return :

1 2 

?

0

    1 Answer 1

    5

    You want your local shell to expand $var1 but the remote shell to expand $var2:

    var1=1 ssh -p 42 root@xxx /bin/bash << EOF # un-quoted/escaped var2=2 echo $var1 echo \$var2 EOF 

      Start asking to get answers

      Find the answer to your question by asking.

      Ask question

      Explore related questions

      See similar questions with these tags.