0

我想从 python 中获取 pw 值,比如

spawn python3 $pscript
expect "password:"
send "$enc_password\r"
set outcome $expect_out(buffer) --getting empty array in outcome

文件.py

import keyring
pw = keyring.get_password("system","user")
print(pw)

让我知道是否有其他方法可以做到这一点。

4

1 回答 1

1

我只是错过了一件事:

spawn python3 $pscript
expect "password:"
send "$enc_password\r"
expect "blah" --this extra expect, else the outcome will be an empty array
set outcome $expect_out(buffer) 
于 2021-07-20T13:19:39.817 回答