Execute script over SSH and get output? [duplicate]
问题 This question already has answers here : Running a Bash script over ssh (5 answers) Closed 3 years ago . 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