代码: 全选
root@ffdf50d37cdd:/# dotnet /miner/Miner.dll /rpc
ant>open wallet /miner_data/wallets/1.db3
password:*
[07:37:21] StartMine
1. 使用dotnet命令启动Miner.dll
2. 使用open wallet命令打开一个文件/miner_data/wallets/1.db3
3. 输入密码
4. 程序正常运行后马上输出StartMine等日志;如果密码错误,出现提示failed to open file "/miner_data/wallets/1.db3"
5. 步骤2、3也可能出现异常信息error,此时从步骤2重新执行即可。
由于我要把这段程序放在Docker生产环境中运行,所以要把这段人工交互过程改成程序自动交互的。初步研究后发现expect命令有这个功能,于是写了下面的一段代码a.sh:
代码: 全选
#!/usr/bin/expect
expect -c "
spawn dotnet /miner/Miner.dll /rpc
expect "ant\>"
send "open wallet /miner_data/wallets/1.db3\r"
expect "password:"
send "1\r"
"
代码: 全选
root@ffdf50d37cdd:/# sh a.sh
spawn dotnet /miner/Miner.dll /rpc
ant>couldn't read file "wallet": no such file or directory
root@ffdf50d37cdd:/#