我想使用 Tcl/expect 自动执行以下交互,脚本启动并且什么也不做期望命令不能期望命令的所有输出
#!/usr/bin/expect
set timeout 10
set user username1
set password password@123
spawn ssh $user@10.100.55.33
expect "Password:"
send "$password\r"
expect eof
send "cv mk ghassan-test-5\r"
sleep 45
expect "ok" { send "cv set ghassan-test-5\r" }
sleep 20
expect -gl "Ok" { send "cv rbset ghassan-test-5\r" }
expect eof
sleep 20
expect -gl "Ok" { send "cv ls\r" }
sleep 10
expect eof
send "exit\r
该send "cv mk ghassan-test-5\r"
命令运行,输出如下
$ cv mk ghassan-test-4 数据库正在写入磁盘,请稍候。 写入数据库文件可能需要几分钟... 行
下一个命令没有运行,没想到“ ok
”
expect "ok" { send "cv set ghassan-test-5\r" }
但如果我期望minutes
它运行
expect "minutes" { send "cv set ghassan-test-5\r" }
" ok
" 输出需要一分钟才能显示
请任何人有同样的问题请帮助我