Writing a Redis client in pure Bash
digitalserb.me
digitalserb.me
Ultimately the point is that a Redis client is possible using just a standard Unixish userland, and sysadmins who interact with Bash all day can easily make use of redis directly and integrate it into existing scripts without installing special client libraries or writing wrappers in Perl or Python.
(Also, /dev/tcp isn't a filesystem, just a simulation of one constructed purely within bash itself, so it wouldn't in fact depend on anything but the relevant networking syscalls.)
$ nc -l 8080 &
[1] 13694
$ echo hi >> /dev/tcp/127.0.0.1/8080
hi
[1]+ Done nc -l 8080
I just tried it on a relatively diverse set of distros. Depending on the version of netcat, if it is an ancient one on an older distribution such as say RHEL4, you have to do:
nc -l -p 8080
However, the same echo command works in all of them.
Btw, the reason why this works even if you dont see anything in /dev/tcp is because when you try to open a socket in bash using /dev/tcp it doesn't talk with the pseudo-filesystem of /dev. Bash actually intercepts the command and issues a connect() to the remote host.