Reputation: 4840
I expected it to print v=1
. Why does this print v=
?
cat<<DONE|ssh user@host
v=1
echo v=$v
DONE
On host
, bash is the shell.
Upvotes: 2
Views: 716
Reputation: 26555
Your code is equivalent to:
echo "v=1;echo v=$v"|ssh user@host
What you want is:
echo 'v=1;echo v=$v'|ssh user@host
You can achieve this by using cat<<'DONE'
instead of cat<<DONE
.
Upvotes: 7
Reputation: 44201
Variables are expanded inside heredocs. You need to escape the $
with a \
Upvotes: 4