The code is the following (on a python 2.7 prompt)
import subprocess as sp
a = sp.Popen(['bash', '-c', 'ssh [REDACTED] cat text.txt'],
stdout=sp.PIPE, stderr=sp.PIPE)
print(a.communicate()[0])
I would expect this program to print the entire "text.txt" file, however, it is missing the last few lines.
The file text.txt is in a remote server, which I assume is the gist of it. If I retrieve the file and then do subprocess.Popen locally, it works as expected.
Why does it happen and how can I fix it?
note: the result is the same if I use check_output