Re: [gentoo-user] Bash Server Sockets
While I don't think there's a way. I took a shell scripting class a year or two ago and we used netpipes for tcp connecrions. Since it was a very bash class we'd have used bash if possible On 1/16/09, Albert Hopkins mar...@letterboxes.org wrote: On Thu, 2009-01-15 at 21:53 -0800, Hilco Wijbenga wrote: Hi all, In Bash /dev/tcp/host/port can be used to write to a TCP socket. This works nicely so I was very curious whether it would work the other way too: is it possible to have a Bash script listen on a particular port as if it were a server? I couldn't find anything in the Bash manual about it. Google does find a few examples but they all use nc. But that's cheating! ;-) Is it possible with just Bash, no extra tools? (If yes, please enlighten me as to how, obviously I could not get it to work.) ... and some would even say using bash to begin with is cheating.
Re: [gentoo-user] Bash Server Sockets
On Thu, 2009-01-15 at 21:53 -0800, Hilco Wijbenga wrote: Hi all, In Bash /dev/tcp/host/port can be used to write to a TCP socket. This works nicely so I was very curious whether it would work the other way too: is it possible to have a Bash script listen on a particular port as if it were a server? I couldn't find anything in the Bash manual about it. Google does find a few examples but they all use nc. But that's cheating! ;-) Is it possible with just Bash, no extra tools? (If yes, please enlighten me as to how, obviously I could not get it to work.) ... and some would even say using bash to begin with is cheating.
[gentoo-user] Bash Server Sockets
Hi all, In Bash /dev/tcp/host/port can be used to write to a TCP socket. This works nicely so I was very curious whether it would work the other way too: is it possible to have a Bash script listen on a particular port as if it were a server? I couldn't find anything in the Bash manual about it. Google does find a few examples but they all use nc. But that's cheating! ;-) Is it possible with just Bash, no extra tools? (If yes, please enlighten me as to how, obviously I could not get it to work.) On a related note, I read some comments about Debian having /dev/tcp disabled in Bash because of security concerns. Would someone knowledgeable about security be able to comment on that? It doesn't make much sense to me. I mean, any Perl, Python, Ruby, etcetera script can write to a socket. Even Debian (with every option deselected) comes installed with Perl. (Yes, I installed Debian just to find out!) :-) So why should /dev/tcp in Bash be deemed such a security risk? Cheers, Hilco P.S. For the curious: #!/bin/bash exec 3/dev/tcp/www.google.ca/80 echo -ne GET / HTTP/1.1\r\n3 echo -ne Host: www.google.ca\r\n3 echo -ne Connection: close\r\n3 echo -ne \r\n3 cat 3