1

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()
4

0 回答 0