bash脚本在expect代码中增加数组索引

时间:2013-06-06 20:36:11

标签: arrays linux bash shell expect

这是我在一些bash脚本中嵌入的代码。

VAR=$(expect -c 'expect {  
       "name:" { send "'${Array[pos]}'"\r" ; exp_continue}  
       "hello" {send "hello\r" ; exp_continue}  
    } 

但是,传递的所需值是存储在数组Array中的字符串。如果它出错了它会继续询问“name:”,正确的值总是在Array中。 我怎样才能每次增加pos值,以便最终进入正确的位置?

由于

1 个答案:

答案 0 :(得分:0)

尝试每次都会增加的${Array[pos++]}

相关问题