I am trying to execute a command in a remote machine and get the output.
I have tried implementing below shell script but unable to get the content.
#!/bin/bash
out=$(ssh huser@$source << EOF
while IFS= read -r line
do
echo 'Data : ' $line
done < "data.txt"
EOF
)
echo $out
Output:
Data : Data : Data :
I could see the "Data :" is printed 3 times because the file "data.txt" has 3 lines of text.
I can't use scp command to get the file directly because I might have to run some command in the place of text file.
Can someone help me in finding the issue?
Thanks in advance.
{}button.echo.