我試圖在winpexpect中使用plink連接到遠程Linux服務器。我使用下面的代碼:在winpexpect中運行plink
child = winpexpect.winspawn('plink [email protected]')
child.logfile = sys.stdout
i = child.expect(['Password:')
child.expect('Password:')
child.sendline('password')
我得到的標準輸出的輸出是:
Using keyboard-interactive authentication.
Password: password
Using keyboard-interactive authentication.
Password:
Using keyboard-interactive authentication.
Password: Traceback (most recent call last):
File "<stdin>", line 1, in <module>
...in expect_loop
raise TIMEOUT (str(e) + '\n' + str(self))
pexpect.TIMEOUT: Timeout exceeded in read_nonblocking().
...
command: plink
args: ['plink', '[email protected]']
buffer (last 100 chars): yboard-interactive authentication.
Password:
Using keyboard-interactive authentication.
Password:
before (last 100 chars): yboard-interactive authentication.
Password:
Using keyboard-interactive authentication.
Password:
after: <class 'pexpect.TIMEOUT'>
...
等效代碼在Pexpect的Linux下(與Pexpect的更換winpexpect模塊和砰砰通話與ssh),所以我知道expect()匹配是正確的。它看起來像winpexpect正在寫入屏幕,並且plink不會將其註冊爲正在輸入密碼字段的文本。
任何人都可以在這裏發現問題嗎?
您是否找到解決方案?我嘗試從BitBucket更改winpexpect腳本沒有成功。謝謝,克里斯 – chrissygormley
不幸的是,我沒有找到解決方案。看起來像winpexpect中的一個bug,但我沒有時間去嘗試自己弄清楚。 – Symmetric