Skip to content

Instantly share code, notes, and snippets.

@bhenderson bhenderson/ncpipe
Last active Dec 18, 2015

Embed
What would you like to do?
NetCat (nc) pipe. Using coproc available in bash 4.
#!/bin/bash
server=$1
port=$2
lport=${3:=$port}
# stdout will be server
# stderr will be client
exec 3>&1
# use coproc instead of named pipe.
# bash 4
coproc { nc $server $port | tee >( cat >&3 ) ;}
{ nc -lk -p $lport | tee >( cat >&2 ) ;} <&${COPROC[0]} >&${COPROC[1]}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.