0

I'm currently trying to find the bug in the following piece of bash code:

for ((v=1; v<=${config[vnc_number]}; v++))
do
        # Do something here
done

for ((l=1; l<=${config[number]}; l++))
do
        # And do something here
done

Inside the loops I'm just creating a few VMs but think this is irrelevant for this question.

The values of config[vnc_number] and config[number] are defined in another file but reading these out works just fine, I tried it.

The first loop works just fine but the wierd thing is that in the second loop it throws the error:

   create_vms.sh: line 109: ((: l<=3
   2: syntax error in expression (error token is "2")

I tried various things to fix it but nothing seems to work so I am asking you guys. Thanks in advance for the help.

  • Which line is line 109? What is the content of `config` array? What are the values of `vnc_numbers` and `number`? Please show `declare -p config`. Did you check your script with http://shellcheck.net ? Well, you showed a tiny (line 109...) part of you code and expect others to guess an error in it. Please post a full [MCVE] so that others can test your code and reproduce the problem. From the error says what is says - I __guess__ the content of `config` array is invalid. – KamilCuk Mar 25 '20 at 13:20
  • Does this answer your question? [Difference between sh and bash](https://stackoverflow.com/questions/5725296/difference-between-sh-and-bash) – oguz ismail Mar 25 '20 at 13:20

0 Answers0