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

标签 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:”,正确的值始终在数组中。 我怎样才能每次增加 pos 以便我最终能找到正确的条目?

谢谢

最佳答案

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

关于arrays - bash脚本在expect代码中增加数组索引,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16971702/

相关文章:

javascript - 从 json 响应中删除双引号

java - 如何解析JSON数组对象textview 1和textview 2

linux - 如何自动化 bash 脚本

linux - inotifywait 命令不检测文件但检测文件夹

linux - uniq 终端命令不起作用?

mysql - 显示按 "on the fly score calculation"排序的带分页的文章的最佳做法是什么

c - C中如何检查服务器端是否建立连接

python - linux 中的 Selenium webdriver 权限问题仍然存在

bash - shell 脚本 : Using bash with xargs

java - 二维数组不是深度克隆,更改会影响两个数组