-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Leonids Maslovs
committed
Mar 6, 2016
1 parent
0e9a57a
commit 66a35f3
Showing
2 changed files
with
22 additions
and
8 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Shell: check tcp port | ||
|
||
Periodically I find myself in th 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][dev-tcp]. | ||
|
||
## Example | ||
|
||
**Source:** http://stackoverflow.com/a/19866239 | ||
|
||
```console | ||
# Connection successful: | ||
$ timeout 1 bash -c 'cat < /dev/null > /dev/tcp/google.com/80' && echo ping || echo fail | ||
ping | ||
``` | ||
|
||
<!-- References --> | ||
[dev-tcp]: http://www.tldp.org/LDP/abs/html/devref1.html#DEVTCP "/dev/tcp" |