我的for循环正在为vp1运行,所有的队列都被选中,与vpn2和vpn3相同,但是vp1应该分别选择queue1和vpn2与queue2 &vpn2 3和queue3,如何实现?
source ./config.csv
vpn="$vpn1 $vpn2 $vpn3"
queue="$queue1 $queue2 $queue3"
for i in $vpn
do
for j in $queue
do
echo "Fetching LVQ details from $i VPN ..."
msgs=$(curl -s -X GET -u ${User}:${PASSWORD} http://${IP}:${Port}/SEMP/v2/monitor/msgVpns/$i/queues/$j/msgs)发布于 2022-04-13 07:03:17
您的脚本正在使用无存在变量来创建数组。你可以试试这个
source ./config.csv
vpn=(vpn1 vpn2 vpn3)
queue=(queue1 queue2 queue3)
n=0
for net in ${vpn[@]}; do
echo "Fetching LVQ details from $net VPN ..."
msgs=$(curl -s -X GET -u "${User}":"${PASSWORD}" http://"${IP}":"${Port}"/SEMP/v2/monitor/msgVpns/"$net"/queues/"${queue[$n]}"/msgs)
((n++))
donehttps://stackoverflow.com/questions/71852176
复制相似问题