Pamela Dragosh | d1728dc | 2017-02-14 19:57:17 -0500 | [diff] [blame] | 1 | #!/bin/bash |
2 | |||||
3 | if [[ $# -ne 2 ]]; then | ||||
4 | echo "Usage: wait-for-port hostname port" >&2 | ||||
5 | exit 1 | ||||
6 | fi | ||||
7 | |||||
8 | host=$1 | ||||
9 | port=$2 | ||||
10 | |||||
11 | echo "Waiting for $host port $port open" | ||||
12 | until telnet $host $port </dev/null 2>/dev/null | grep -q '^Connected'; do | ||||
13 | sleep 1 | ||||
14 | done | ||||
15 | |||||
16 | echo "$host port $port is open" | ||||
17 | |||||
18 | exit 0 |