Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
23 lines (15 sloc) 616 Bytes

Shell: check tcp port

Periodically I find myself in the need to check for TCP port availability; and no convenient tools available and not possible to install one.

Usually I use netcat -z -v cidrc port or telnet.

Lately I've found quite useful some under-appreciated feature of bash shell. See /dev/tcp.



# Connection successful:
$ timeout 1 bash -c 'cat < /dev/null > /dev/tcp/' && echo ping || echo fail