To get data back from a network daemon using this technique is quite trivial, if you are using an X windows desktop. Simply open up two xterms. xterm 1: # tee rx.log </dev/tcp/<host>/<port>
xterm 2: # echo <arbitrary message>| tee tx.log >/dev/tcp/<host>/<port> Send whatever you want to your remote host, and watch the response spew out on your terminal. You can also go back through the logs later if you like. Erik Johnson On Fri, Feb 27, 2009 at 7:09 AM, Steffen Maier <[email protected]> wrote: > On 02/27/2009 09:28 AM, John Summerfield wrote: >> John McKown wrote: >>> First: using redirection to write to or read from an IP port >>> >>> command >/dev/tcp/${HOST}/${PORT} > >> but how does one carry on a sensible conversation? I can send stuff to >> sendmail, but how do I get its responses? > > See bftpget (an ftp client with bash-builtins only) in > ftp://ftp.heise.de/pub/ct/listings/0702-178.zip > (from an article in a german journal which is unfortunately not freely > available on the net: > http://www.heise.de/kiosk/archiv/ct/2007/2/178_kiosk). > >> 16:23 [sum...@bobtail ~]$ ls -l /dev/tcp/ns >> ls: /dev/tcp/ns: No such file or directory >> 16:24 [sum...@bobtail ~]$ ls -l /dev/tcp/ns:22 >> ls: /dev/tcp/ns:22: No such file or directory > > AFAIK, these are pseudo files handled internally by bash, so they won't > appear in the file system. > >>> <( command ) and >( command ) > [snip] >>> via a /dev/fd/n. > > Bash meanwhile implements process substitution by means of /dev/fd, > optionally by means of named pipes (FIFOs). > >> I think this sort of thing is a bit OS-dependent. It works with some >> (2.4 and later I suspect) Linux kernels, likely not with *BSD, Solaris >> and such, but I don't have any alternative systems to test on. > > Linux implements /dev/fd as a symlink to /proc/self/fd. > I found /dev/fd/... available on Solaris 10 (on Sparc) implemented with > character devices. > >> (echo >&5) 5>tempfile >> where tempfile could be something above. I've used this sometimes in >> scripts: think of any kind of program that produces more than one report >> and you will find a use. > > Redirection of arbitrary file descriptors is very handy, especially in > combination with the exec shell builtin. E.g., configure from autoconf > makes heavy use of it. > > Steffen > > Linux on System z Development > > IBM Deutschland Research & Development GmbH > Vorsitzender des Aufsichtsrats: Martin Jetter > Geschäftsführung: Erich Baier > Sitz der Gesellschaft: Böblingen > Registergericht: Amtsgericht Stuttgart, HRB 243294 > > ---------------------------------------------------------------------- > For LINUX-390 subscribe / signoff / archive access instructions, > send email to [email protected] with the message: INFO LINUX-390 or visit > http://www.marist.edu/htbin/wlvindex?LINUX-390 > ---------------------------------------------------------------------- For LINUX-390 subscribe / signoff / archive access instructions, send email to [email protected] with the message: INFO LINUX-390 or visit http://www.marist.edu/htbin/wlvindex?LINUX-390
