[英]using a bash variable inside expect
我有一個名為profiles.txt 的文件,每一行都包含一個數字,即
11
24
35
46
使用下面的腳本,我讀取文件並將每一行存儲為一個變量,我遇到的問題是我無法在期望部分使用這個變量。 有沒有辦法做到這一切?
while IFS= read -r line; do
printf -v "profile$((i++))" '%s' "$line"
done < profiles.txt
/usr/bin/expect <(cat << EOF
spawn telnet 0.0.0.0
send -- "$profile1\r"
send -- "exit\r"
EOF
)````
在while
內移動expect
:
while IFS= read -r line; do
/usr/bin/expect <(cat << EOF
spawn telnet 0.0.0.0
send -- "$line\r"
send -- "exit\r"
EOF
)
done < /tmp/input
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.