In cygwin, I am trying to setup a netcat proxy, as follows:
-
The server: in one terminal I am running
nc -lp 6000 -
The proxy: in a second terminal I am running the proxy (listening on 2000 and passing farther to 6000).
-
The client: in a third terminal I am running
nc localhost 2000
The test
Typing something in client should show up on server. Typing something in server, should show up on client.
Below is what I tried to do in the 2nd terminal:
-
This one works fine:
nc -lp 2000 <fifo | tee /dev/stderr | nc localhost 6000 >fifo
(where fifo was previously setup with “mkfifo fifo”)
-
But… these do not work 🙁
nc -lp 2000 <fifo | awk '{print}' | nc localhost 6000 >fifo nc -lp 2000 <fifo | awk -f my.awk | nc localhost 6000 >fifo nc -lp 2000 <fifo | awk -f my.awk - | nc localhost 6000 >fifo
(where my.awk contains just {print})
Please helppppppppppppppp!!!!!!!!
Thanks in advance,
Adrian.
The problem is due to buffering and there is no standard way to turn it off in awk. On some systems you can hack around it by calling
fflush, for example:Sadly this doesn’t always work depending on platform and awk version. You might consider using a different processor that allows you to disable buffering, such as Perl.