netcat man page: -e emulation

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

netcat man page: -e emulation

Pete Vickers
Hi,

The traditional netcat had a -e option to "Execute the specified  
command, using data from the network for stdin, and sending stdout  
and stderr to the network..."
Whilst I can understand that this option might not be desirable to be  
included in the binary (for security reason ?), I occasionally find  
it very useful, and so emulate it with a shell script:

$ cat wetcat
#!/bin/ksh
CMD="$*"
LISTEN_PORT=1234
MYPID=$$
FIFO=/tmp/${RANDOM}_${MYPID}.fifo
mkfifo -m 600 $FIFO
($CMD < $FIFO )  2>&1 | nc -l $LISTEN_PORT > $FIFO
rm $FIFO

If others would find it useful too, maybe it could be added to the  
examples section of the nc(1) man page ?

/Pete

Reply | Threaded
Open this post in threaded view
|

Re: netcat man page: -e emulation

John Wright-6
How about

#!/bin/ksh
nc -l localhost 1234 |&
exec 0<&p 1>&p
# Rest of the script here.

This syntax is pretty new to me so I'm not sure of pros and cons.