//View Tip #196
Similar Tips
» Randomize lines in a file
» ESC-g for glob expansion in bash
» Stream shell commands to Twitter
» Change extension of files in the current directory
» Tar remote dir over SSH


Latest tips by RSS
Click here to subscribe
Follow Shell-Fu on Twitter
Click here to follow
Follow Shell-Fu on identi.ca
Click here to follow
Don't have telnet or netcat handy for making a socket connection? Most Linux distros - not likely Debian - have this functionality built directly into Bash. The following will pull my site's index source on port 80, replace with any URL.


exec 3<>/dev/tcp/kinqpinz.info/80
echo -e "GET / HTTP/1.1\nHost: kinqpinz.info;\nConnection: close\n\n">&3
cat <&3

View Comments »


Add your comment

Comments are currently disabled
gawk does something similar with /inet/tcp see: http://www.gnu.org/software/ga … 2ftcp.html
Posted 2009-02-07 19:54:57
From the bash man page:

NOTE: Bash, as packaged for Debian, does not support using the /dev/tcp and /dev/udp files.

This means that for popular distributions like Ubuntu GNU/Linux 8.04, you may have to compile a custom bash first.
Posted 2009-02-07 20:34:03

Home Latest Browse Top 25 Random Hall Of Fame Contact Submit