リモートサーバーに接続するためのSudo Pythonコードですが、出力が得られません。pexpect を使用してリモートに接続できますが、Windows では機能しません。
from subprocess import Popen,PIPE
command = "plink.exe -ssh test@test.com -pw root123"
sh = Popen(command, stdin=PIPE, stdout=PIPE)
sh.stdin.write('ls /\n')
sh.stdin.write('ls /usr\n')
sh.stdin.close()
out = sh.stdout.read()