I have the following nice bash command :
cat SomePythonScript.py | ssh remote_machine 'cat - | python'
that works very fine and that I want to write in Python. I tried with 'subprocess' but did not get that far. Can someone help me ?
from subprocess import PIPE , Popen
p1 = Popen(["cat ", "SomePythonScript.py"], stdout=PIPE)
p2 = Popen(["remote_machine"], stdin=p1.stdout, stdout=PIPE)
p3 = Popen(["cat -", "python"], stdin=p2.stdout, stdout=PIPE)
p1.stdout.close()
p2.stdout.close()
output = p3.communicate()[0]
I tried also with 2 processes/ pipes
from subprocess import PIPE , Popen
p1 = Popen([["cat", "SomePythonScript.py"], stdout=PIPE)
p2 = Popen(["remote_machine","cat", "- python"], stdin=p1.stdout, stdout=PIPE)
p1.stdout.close()
output = p2.communicate()[0]
I would be very glad to any help, suggestion , advices, explanation solution... Thk in advance