Re: How to redirect stdout to stdin?
- From: Stephane CHAZELAS <stephane_chazelas@xxxxxxxx>
- Date: Wed, 21 May 2008 08:30:49 +0000 (UTC)
2008-05-20, 19:24(-04), Wayne:
Wenhua Zhao wrote:
Hi,
I am trying to use `nc' to make a echo service. So I need to redirect
stdout of nc to its stdin. I tried
$ nc -l 6000 1>&0
But it does not work. What is correct way to do this?
If you could connect the output of a command to its input,
you'd end up with an infinite loop.
Depends what the commands do with their input and output.
Typically, with nc, it wouldn't cause such a loop, because what
nc reads from stdin it sends over a TCP socket, and it writes to
its stdout what it reads from that socket (what's coming from
the other end, not what nc wrote to it).
[...]
[...]A similar question is how to use IO redirection to set up a
bidirectional pipe between two processes? Suppose I want to direct
the output of `A' to `B', and direct the output of `B' to `A' at the
same time, what should I do?
Use a pair of pipes, at least one of which must be a named pipe
(or "FIFO"). See mkfifo command.
Some newer shells have built-in support for this.
Are you refering to ksh or zsh coprocesses?
A |& # ksh
coproc A # zsh
B <&p >&p
Again, beware of deadlocks (especially when stdio (or other)
buffering comes into play).
--
Stéphane
.
- References:
- How to redirect stdout to stdin?
- From: Wenhua Zhao
- Re: How to redirect stdout to stdin?
- From: Wayne
- How to redirect stdout to stdin?
- Prev by Date: Re: How to redirect stdout to stdin?
- Next by Date: Re: test if awk
- Previous by thread: Re: How to redirect stdout to stdin?
- Next by thread: Re: How to redirect stdout to stdin?
- Index(es):
Relevant Pages
|