在发出“ send”命令的命令正在打印输出时,是否可以重置超时计时器?
这种情况是,我想在许多服务器上运行类似find / -exec head {} /;
的命令。我希望在命令打印输出时重置计时器。我不想将超时设置为小时...
谢谢!
答案 0 :(得分:1)
使用exp_continue
,可以做到这一点。
set threshold 1
set timeout 60; # 1 min
send "find / -exec head {} / \r"
expect {
# Your prompt here
"#"; {puts "prompt matched. cmd completed"}
timeout {
# Checking for max of 10 mins
if {$threshold>10} {
puts "output took more time than threshold"
exit 1
}
incr threshold
puts "Still waiting for the prompt"
# The below command will reset the expect timer
# and will cause the same expect loop to run again
exp_contintue;
}
}