Tech Tip: TCP/IP Access Using bash
Most of us default to wget, curl, netcat and others when in need of network data from the commandline, not knowing, or perhaps forgetting, that bash often provides the support that we need using redirection from /dev/proto/host/port.
$ cat </dev/tcp/time.nist.gov/13 55103 09-09-29 17:58:55 50 0 0 0.0 UTC(NIST) *
Reads the time in Daytime Protocol (RFC-867) from the NIST Internet Time Service server (documented at tf.nist.gov/service/its.htm).
The Advanced Bash-Scripting Guide includes some more involved examples in chapter 27, covering sending a protocol request, getting web pages, and even UDP use.
Editor's Note: If this does not work for you, make sure to read the comments below, this option is not enabled on all distros (among them, some versions of Ubuntu).
- Transitioning to Python 3
- Returning Values from Bash Functions
- Linux Journal December 2016
- Radio Free Linux
- Red Hat OpenStack Platform
- Tech Tip: Really Simple HTTP Server with Python
- Stepping into Science
- CORSAIR's Carbide Air 740
- A Better Raspberry Pi Streaming Solution
- FutureVault Inc.'s FutureVault