[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

python3 subprocess run sudo cmd in remote failed

Hello, I use python3.5 and found no way to solve this problem

>from subprocess import Popen, PIPE
>ps = Popen('ssh -o \'StrictHostKeyChecking no\' hello at \'sudo
sysctl -w vm.drop_caches=3\', stdin=PIPE, stdout=PIPE, stderr=PIPE,
bufsize=0, shell=True)
>  hello at's password:

what I tried many times like enter password, but it failed.
I just want to use ps.stdin.write(password) to send password, but it always
jump password prompt immediately.

How to solve this