I am trying to read an output from an interactive session and wait for the next command. This is performed using RPyC connection.
Example:
from subprocess import Popen, PIPE
from time import sleep
import sys
import rpyc
rp = rpyc.classic.connect("x.x.x.x", port=18812)
sp = rp.modules.subprocess.Popen("openssl",
stdin=rp.modules.subprocess.PIPE,
stdout=rp.modules.subprocess.PIPE,
stderr=rp.modules.subprocess.PIPE,
shell=True)
print(sp)
# Send Command #1
sp.stdin.write("speed rsa2048\n".encode())
sp.stdin.flush()
sleep(0.1)
data = sp.stdout.read() # Script hangs here
print(data.decode())