[英]how to capture the python output in a shell variable from expect?
我想從 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)
如果有其他方法可以做到這一點,請告訴我。
我只是錯過了一件事:
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)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.