3 ms·
I have been using/administering GNU/Linux based systems for 15 years and have yet to see where the Bash built-in /dev/tcp was enabled, so any shell script I wri
by joshbaptiste 12y ago
I have been using/administering GNU/Linux based systems for 15 years and have yet to see where the Bash built-in /dev/tcp was enabled, so any shell script I write that requires sockets I reach for netcat or socat.
- MPSimmons 12y agoI just tried it on stock Ubuntu 14.04, Linux Mint, and a CentOS box, and it worked fine.
- SEJeff 12y agoI think you are mistaken. /dev/tcp is not visible in /dev or devtmpfs, however it most definitely works. $ 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.
- crypt1d 12y agoExactly. Its been available for a while now on most distros, I even used it on some legacy AIX systems running Korn shell. 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.