我使用Spectrespectre-cli
的交互式钱包,这种代币的设计与 Kaspa 类似。当我想要手动获取钱包余额时,我需要
在 中运行,然后运行。所有这些看起来都像这样:spectre-cli
connect
open
spectre-cli
spectre-cli
Spectre Cli Wallet v0.3.16 (type 'help' for list of commands)
$ connect
Connected to Spectre node version 0.3.16 at ws://127.0.0.1:19110
$ open
Enter wallet password:
Your wallet hint is: This is a hint.
$ $
• ****************
• [********]: 4.47042578 SPR 1 UTXOs
spectre:******************************************************
[********] • 4.47042578 SPR $
我编写了一个预期脚本来帮我完成这些步骤(这样我唯一需要输入的就是我的密码):
#!/usr/bin/expect -f
# Set a timeout (in seconds) for how long to wait for each prompt
set timeout 5
spawn spectre-cli
expect "$ "
send "connect\r"
expect "$ "
send "open\r"
interact
我从脚本中得到不一致的输出。大约 70% 的时间我得到:
./get_balance_works.exp
spawn spectre-cli
Spectre Cli Wallet v0.3.16 (type 'help' for list of commands)
$ connect
connectopen
command not found: connectopen
$
其余时间脚本都按预期工作:
./get_balance_works.exp
spawn spectre-cli
Spectre Cli Wallet v0.3.16 (type 'help' for list of commands)
$ connect
$ open
Connected to Spectre node version 0.3.16 at ws://127.0.0.1:19110
Enter wallet password:
Your wallet hint is: This is a hint.
$ $
• ****************
• [********]: 4.47042578 SPR 1 UTXOs
spectre:******************************************************
[********] • 4.47042578 SPR $
有没有办法让脚本以一致的方式按预期工作?
PS 我在使用 Ubuntu LTS。