0

just playing around on my server to get script the setup of the next server. Everything works - now I want to run it on the new server i got an error like this:

sudo sh setup.sh Hostname is dinozzo setup.sh: 10: setup.sh: [[: not found

The Script to start is not that much. Line 10 is

if [[ "$INT_DEV_HOSTNAME" ]]; then

But I don't get it why it is not working on Ubuntu 14.04.5 LTS.

sCHween
  • 113
  • 2
  • 12
  • The question was already answered here http://stackoverflow.com/questions/3601515/how-to-check-if-a-variable-is-set-in-bash – agg3l Oct 21 '16 at 14:06
  • 2
    `sh` is not the same as `bash`. `[[` is a bash-ism -- so execute the script with `bash` instead. – FatalError Oct 21 '16 at 14:06

1 Answers1

3

You explicetly tell the shell to use sh :

sudo sh setup.sh Hostname is dinozzo setup.sh: 10: setup.sh: [[: not found

In this mode, even if it's that you are using by default, it will produce the error because it will be in POSIX mode.

[[ ]] form of test need to be called from within a shell (other shells support it too, like ksh, zsh...)

Gilles Quénot
  • 173,512
  • 41
  • 224
  • 223