I was wondering if I could get this down to just a few lines of code then realized that the shell should be able to handle this. Turns out it works okay.
In terminal a: $ while /bin/true; do echo date; sleep 1; done | nc localhost 9999 In terminal b I run: ( nc -d -l 9999 & cat) | bash And I see Wed Oct 26 19:21:54 PDT 2011 Wed Oct 26 19:21:55 PDT 2011 Wed Oct 26 19:21:56 PDT 2011 Wed Oct 26 19:21:57 PDT 2011 In terminal b if I say ls -al: Wed Oct 26 19:23:09 PDT 2011 ls -al total 16 drwxrwsr-x 2 bill bill 4096 2011-10-26 19:18 . drwxrwsr-x 143 bill bill 12288 2011-10-26 19:18 .. -rw-rw-r-- 1 bill bill 0 2011-10-26 19:18 filea -rw-rw-r-- 1 bill bill 0 2011-10-26 19:18 fileb Wed Oct 26 19:23:10 PDT 2011 A nice side effect is if I type slowly in terminal B: Wed Oct 26 19:24:26 PDT 2011 tWed Oct 26 19:24:27 PDT 2011 oWed Oct 26 19:24:28 PDT 2011 uWed Oct 26 19:24:29 PDT 2011 cWed Oct 26 19:24:30 PDT 2011 hWed Oct 26 19:24:31 PDT 2011 fWed Oct 26 19:24:32 PDT 2011 ilecWed Oct 26 19:24:33 PDT 2011 Wed Oct 26 19:24:34 PDT 2011 ls filea fileb filec Wed Oct 26 19:24:35 PDT 2011 So basically the buffering means that the streams don't stomp on each other unnecessarily. Assuming there's a nc/bash port to windows or a functional equivalent it should work there as well. Not pretty, but it seems workable. You could of course have perl/python send or receive in either terminal A or B. _______________________________________________ vox-tech mailing list [email protected] http://lists.lugod.org/mailman/listinfo/vox-tech
