通过提供默认值为安装编写了expect脚本。它没有正确安装,并且在执行期间,它不是控制台上的执行进度。
#!/usr/bin/expect -f
cd /opt/hyperic-hqee-agent-5.8.6
exec rm -rf data
cd bin
exec ./hq-agent.sh stop
exec ./hq-agent.sh start
expect ": $"
send "\r"
expect ": $"
send "10.152.24.109\r"
expect ": $"
send "\r"
expect ": $"
send "\r"
expect ": $"
send "\r"
expect ": $"
send "hqadmin\r"
expect ": $"
send "\r"
expect ": $"
send "\r"
expect ": $"
send "yes\r"
答案 0 :(得分:0)
exec
命令返回标准输出。如果要打印,请使用
puts [exec external_command]
答案 1 :(得分:0)
我犯了错误。而不是'exec',我应该使用'spawn'。它只是作为一个shell命令而没有交互。
cd bin
spawn ./hq-agent.sh stop
expect ":$"
spawn ./hq-agent.sh start
expect ": $"
send "\r"
expect ": $"
.
..
.
interact
感谢您帮助我。