2 # https://github.com/Eficode/wait-for.git
9 if [ "$QUIET" -ne 1 ]; then printf "%s\n" "$*" 1>&2; fi
16 $cmdname host:port [-t timeout] [-- command args]
17 -q | --quiet Do not output any status messages
18 -t TIMEOUT | --timeout=timeout Timeout in seconds, zero for no timeout
19 -- COMMAND ARGS Execute command with args after the test finishes
26 for i in `seq $TIMEOUT` ; do
27 nc -z "$HOST" "$PORT" > /dev/null 2>&1
29 if [ $result -eq 0 ] ; then
30 if [ "$QUIET" -ne 1 ]; then echo "Operation succeeded on try $i"; fi
31 if [ -n "$command" ] ; then
38 echo "Operation timed out" >&2
46 HOST=$(printf "%s\n" "$1"| cut -d : -f 1)
47 PORT=$(printf "%s\n" "$1"| cut -d : -f 2)
56 if [ "$TIMEOUT" = "" ]; then break; fi
71 echoerr "Unknown argument: $1"
77 if [ "$HOST" = "" -o "$PORT" = "" ]; then
78 echoerr "Error: you need to provide a host and port to test."