简体   繁体   中英

Need Help in Bash debugging

Im trying to run this code . Basically I want the https://admin:qwerty123@ '"$dmp"':7777/set_param?'"$params command to run 3 times for every ip in array. But Im getting errors like

prog.sh: line 7: syntax error near unexpected token `while'
prog.sh: line 7: `while [ $n -lt 3 ]; do'

Please can someone correct the code

#!/bin/bash 

n="0"
dmps=(10.104.164.104 10.35.176.77 10.35.176.126) # *****  put your dmp ips here *******

for dmp in ${dmps[@]}; 
while [ $n -lt 3 ]; do


  do res=$(curl -k -s --url 'https://admin:qwerty123@'"$dmp"':7777/set_param?'"$params"); 
  echo "DMP: $dmp - $res"; 
n=$[n+1]
done

done
  • add space before [
  • add ; do ; do after ]

     while [ n -lt 3 ]; do 

read more

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM