> > Well, there's a Python library called "paramiko" which implements ssh. > That might help. > > Later I will try lol.
> Note also that since stdin and stdout are pipes and not the terminal > then ssh will not be interactive, and will not allocate a tty at the far > end either. You can get ssh to open a remote tty with the -t option. > > But I suspect you don't want stdin=PIPE or stdout=PIPE at all. Why are > they there? > > I thought I can use ps.stdin.write(password), so I make stdin and stdout be pipe as input and output. Here are I tried: >from subprocess import Popen, PIPE >ps = Popen('ssh -o \'StrictHostKeyChecking no\' hello@192.168.80.11 \'sudo sysctl -w vm.drop_caches=3\', shell=True) > hello@192.168.80.11's password: >from subprocess import Popen, PIPE >ps = Popen(['ssh', '-o \'StrictHostKeyChecking no\'', ' hello@192.168.80.11', '\'sudo sysctl -w vm.drop_caches=3\'']) > hello@192.168.80.11's password: It always prompt immediately, that make me hard to enter password. Maybe I should try paramiko... -- https://mail.python.org/mailman/listinfo/python-list