【发布时间】:2013-06-06 20:36:11
【问题描述】:
这是我嵌入到一些 bash 脚本中的代码。
VAR=$(expect -c 'expect {
"name:" { send "'${Array[pos]}'"\r" ; exp_continue}
"hello" {send "hello\r" ; exp_continue}
}
但是,传递的所需值是存储在数组 Array 中的字符串。如果它弄错了,它会继续询问“name:”,正确的值总是在数组中。 如何每次都增加 pos 以便最终找到正确的条目?
谢谢
【问题讨论】:
标签: arrays linux bash shell expect