bash is terrifying me again


:) fishsticks$ exec 5<>/dev/tcp/www.perl.org/80
:) fishsticks$ echo -e "GET / HTTP/1.0\nHost: www.perl.org\n\n" >&5
:) fishsticks$ head -1 <&5
HTTP/1.1 200 OK
:) fishsticks$  ls /dev/tcp
ls: /dev/tcp: No such file or directory

Potentially handy, yes, but yeeesh.


11 responses to “bash is terrifying me again”

  1. Maybe I have been stuck in arm-linx-2.4 land and OS X land for too long or maybe I have been using tcsh for too long, but I don’t get it. /dev/tcp?

    I do get the smiley-return-value thing. I may have to start using something like that!

  2. Maybe I have been stuck in arm-linx-2.4 land and OS X land for too long or maybe I have been using tcsh for too long, but I don’t get it. /dev/tcp?

    It’s just icky but neato! bash now supports sockets, and the syntax for accessing them uses “paths” that don’t exist anywhere but in bash’s little imagination.

  3. Interesting, but it doesn’t work here. What is /dev/tcp/blahblahblah interface? Is it a bashism or OSism? If second what OS? If Linux what am I missing? :)

  4. I found what I am missing. In Debian (and clones) bash is compiled without socket support.