0

I have a problem with the done. It says I have some typo error but I can't figure what's wrong at all. Here is the code:

#./bin/bash
until [$err == 0];
do
    java -Xms512m -Xmx512m -cp lib/*:lib/uMad/*:mysql-connector-java-5.1.15-bin.jar:l2jfrozen-core.jar com.l2jfrozen.gameserver.GameServer
    err=$?
    sleep 5
done
Barmar
  • 741,623
  • 53
  • 500
  • 612

2 Answers2

2

Your shebang line is wrong. #./bin/bash will not execute bash.

It should read #!/bin/bash. You are probably using a shell other than bash to invoke this script.

Also, beware that the [$err == 0] line expands the value of $err, which is probably an empty string, unless it has been exported. If it's empty, this will result in an error, because Bash will be interpreting [ == 0].

The safest approach is this:

unset err
until [ "$err" == "0" ];
do
    # etc...
done
paddy
  • 60,864
  • 6
  • 61
  • 103
0

From my experience when working with brackets and if loops, you need proper spacing and double, not single brackets. There needs to be space on each side of the double brackets with the exception of the semi-colon. Here is an example block:

#!/bin/bash

err=5
until [[ $err == 0 ]]; do
    ((err-=1));
    echo -e "$err\n";
    sleep 3
done

I do not see why the same would not apply to a do until loop.

You're probably aware but your heading has a period in it instead of a shebang.

#./bin/bash
Aguevara
  • 91
  • 8