-1

I am doing a bash script with the web api of checkpoint.

126: No such file or directory

this error refers to line 25 in which I have the next sentence:

while [$reglas < $n_reglas ];do

I have tried changing that to:

while [$reglas -lt $n_reglas ];do

but the error persist and I am not sure of what is the real problem.

The variables are defined like this:

reglas=1
n_reglas=$(echo $rulebase_list | jq '.total')

and I have printed their value in order to check that they are taking the correct value. Any idea of which is the problem? Thanks!

Michael Kargl
  • 662
  • 10
  • 21
  • 2
    Welcome to SO, on SO OP has to post samples of input and output in code tags along with that efforts that OP has put to solve his/her problem too in post, so kindly do so and let us know then. This is not clear. – RavinderSingh13 Nov 14 '18 at 09:00
  • Try `while [ $reglas -lt $n_reglas ]; do` (note the space after the opening bracket) or `while ((reglas < n_reglas)); do`. – TrebledJ Nov 14 '18 at 09:02
  • Happy that the answer helped, what was the cause / what fixed it? Could you write a short comment to my answer? I might be able to update it to be more helpful for others comming along this road :) – Michael Kargl Nov 14 '18 at 16:06
  • the bug was that I was doing reglas=$reglas+1 and that make a string which was 1+1, so I use reglas=$(echo $((regkas+1))) as in the example of Michael – unai abrisketa sanchez Nov 15 '18 at 10:31

1 Answers1

1

Unfortunately it is not very clear what the actual problem is. Please try to reproduce the problem in a small code snippet that we can execute and troubleshoot. This way we don't need to guess and can provide more precise help.

Here is a small snippet with a ton of assumptions.

reglas=1
n_reglas=4 # https://jqplay.org/s/BCTXyJ4NLc

while [ $reglas -lt $n_reglas ]; do
   echo $reglas
   reglas=$(($reglas+1))
done

# $bash -f main.sh
# 1
# 2
# 3
Michael Kargl
  • 662
  • 10
  • 21