views:

108

answers:

1

I have a background process read from named pipe. for example

mkfifo /tmp/log.pipe

./myprog.sh < /tmp/log.pipe

I want to use &3 instead of specify /tmp/log.pipe

echo "aaa" >&3 but results similar to echo "aaa" > /tmp/log.pipe

How can I redirect &3 to /tmp/log.pipe everytime.

+3  A: 
exec 3>/tmp/log.pipe
Ignacio Vazquez-Abrams
I tried it but the shell waits for something. I have to Ctrl+C to back to normal. What does it wait?I use bourne shell
teerapap
It's meant to be used in a script.
Ignacio Vazquez-Abrams
oh Thank you. So I have to put `exec 3>/tmp/log.pipe` line in every script? Is there a way to set this globally?
teerapap
There is a way around it, but it is *very* hackish, and your scripts will crash if you don't remember to do it each time. It would probably be best if you put it in each individual script that requires it. In short, write a script that does the exec and then invokes a shell.
Ignacio Vazquez-Abrams
thanks very much
teerapap