Home > OS >  wait-for-it Command not found when run inside a .sh file
wait-for-it Command not found when run inside a .sh file

Time:03-25

Say I'm executing a file named run.sh. I have this commands inside this file:

SERVER=${SERVER:-"localhost:5555"}
wait-for-it ${SERVER}

When I echo the ${SERVER}, I can see that it is correctly set to newserver:5555. When I run run.sh file, I get this error:

Command 'newserver:5555' not found

What am I doing wrong?

UPDATE: "wait-for-it is a script that will wait on the availability of one or more TCP services (i.e. host:port) before executing a user-defined command."

CodePudding user response:

From the wait-for-it website that you linked:

Usage: wait-for-it [OPTIONS] [COMMANDS]...

  Wait for service(s) to be available before executing a command.

Options:
  -h, --help               Show this message and exit.
  -v, --version            Show the version and exit.
  -q, --quiet              Do not output any status messages
  -p, --parallel           Test services in parallel rather than in serial
  -t, --timeout seconds    Timeout in seconds, 0 for no timeout  [default: 15]
  -s, --service host:port  Services to test, in one of the formats: ':port',
                           'hostname:port', 'v4addr:port', '[v6addr]:port' or
                           'https://...'

So you probably want:

SERVER=${SERVER:-"localhost:5555"}
wait-for-it --service ${SERVER}
  • Related