Store output of a script run over ssh in a variable

I’m trying to capture output of a script (resides on a remote server) run over SSH into a variable, below is my code:

ssh username@hostname << EOF
echo $variable

When i run the above script, nothing gets stored in the variable and echo of that variable returns nothing.

What am I doing wrong?

Source: shell

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.