如何从 expect 捕获 shell 变量中的 python 输出?
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
file.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)
我想从 python 获取 pw 值,类似于
spawn python3 $pscript
expect "password:"
send "$enc_password\r"
set outcome $expect_out(buffer) --getting empty array in outcome
file.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)