Wait For It

Pure bash script to test and wait on the availability of a TCP host and port
Alternatives To Wait For It
Project NameStarsDownloadsRepos Using ThisPackages Using ThisMost Recent CommitTotal ReleasesLatest ReleaseOpen IssuesLicenseLanguage
Croc22,892
21 hours ago132May 18, 2022119mitGo
Easily and securely send things from one computer to another :crocodile: :package:
Masscan21,138
20 hours ago1February 27, 2018387otherC
TCP port scanner, spews SYN packets asynchronously, scanning entire Internet in under 5 minutes.
Wait For It8,267
6 months agoSeptember 23, 202275mitPython
Pure bash script to test and wait on the availability of a TCP host and port
Sish3,4231a month ago34November 12, 20219mitGo
HTTP(S)/WS(S)/TCP Tunnels to localhost using only SSH.
Openwrt Shadowsocks2,988
3 years ago1gpl-3.0Makefile
Shadowsocks-libev for OpenWrt/LEDE
Server2,644
4 months ago75mitJavaScript
server for localtunnel.me
Kubernetes Security Best Practice2,323
4 years ago10apache-2.0
Kubernetes Security - Best Practice Guide
Slipstream1,764
5 months ago5Perl
NAT Slipstreaming allows an attacker to remotely access any TCP/UDP services bound to a victim machine, bypassing the victim’s NAT/firewall, just by anyone on the victim's network visiting a website
Tcpflow1,556
2 months ago1February 27, 201867gpl-3.0C++
TCP/IP packet demultiplexer. Download from:
Edumeet1,105
22 days ago4February 02, 202262mitJavaScript
edumeet - multiparty web-meetings using mediasoup and WebRTC
Alternatives To Wait For It
Select To Compare


Alternative Project Comparisons
Readme

wait-for-it

wait-for-it.sh is a pure bash script that will wait on the availability of a host and TCP port. It is useful for synchronizing the spin-up of interdependent services, such as linked docker containers. Since it is a pure bash script, it does not have any external dependencies.

Usage

wait-for-it.sh host:port [-s] [-t timeout] [-- command args]
-h HOST | --host=HOST       Host or IP under test
-p PORT | --port=PORT       TCP port under test
                            Alternatively, you specify the host and port as host:port
-s | --strict               Only execute subcommand if the test succeeds
-q | --quiet                Don't output any status messages
-t TIMEOUT | --timeout=TIMEOUT
                            Timeout in seconds, zero for no timeout
-- COMMAND ARGS             Execute command with args after the test finishes

Examples

For example, let's test to see if we can access port 80 on www.google.com, and if it is available, echo the message google is up.

$ ./wait-for-it.sh www.google.com:80 -- echo "google is up"
wait-for-it.sh: waiting 15 seconds for www.google.com:80
wait-for-it.sh: www.google.com:80 is available after 0 seconds
google is up

You can set your own timeout with the -t or --timeout= option. Setting the timeout value to 0 will disable the timeout:

$ ./wait-for-it.sh -t 0 www.google.com:80 -- echo "google is up"
wait-for-it.sh: waiting for www.google.com:80 without a timeout
wait-for-it.sh: www.google.com:80 is available after 0 seconds
google is up

The subcommand will be executed regardless if the service is up or not. If you wish to execute the subcommand only if the service is up, add the --strict argument. In this example, we will test port 81 on www.google.com which will fail:

$ ./wait-for-it.sh www.google.com:81 --timeout=1 --strict -- echo "google is up"
wait-for-it.sh: waiting 1 seconds for www.google.com:81
wait-for-it.sh: timeout occurred after waiting 1 seconds for www.google.com:81
wait-for-it.sh: strict mode, refusing to execute subprocess

If you don't want to execute a subcommand, leave off the -- argument. This way, you can test the exit condition of wait-for-it.sh in your own scripts, and determine how to proceed:

$ ./wait-for-it.sh www.google.com:80
wait-for-it.sh: waiting 15 seconds for www.google.com:80
wait-for-it.sh: www.google.com:80 is available after 0 seconds
$ echo $?
0
$ ./wait-for-it.sh www.google.com:81
wait-for-it.sh: waiting 15 seconds for www.google.com:81
wait-for-it.sh: timeout occurred after waiting 15 seconds for www.google.com:81
$ echo $?
124

Community

Debian: There is a Debian package.

Popular Port Projects
Popular Tcp Projects
Popular Networking Categories

Get A Weekly Email With Trending Projects For These Categories
No Spam. Unsubscribe easily at any time.
Python
Testing
Bash
Port
Tcp
Bash Script