redirect stdout & stderr to different programs

Hi!

I'm trying to make a program run in a background (like a daemon) and redirect it's output to syslog. So I've prepared rc.d script with the following option:
Code:
command_args="| logger -p daemon.info -t $name &"
It works fine. But I also want to redirect program stderr to other log level (e.g. daemon.err).
So, I'm looking for a way (in rc.d script) to redirect program's stdout to one process (logger -p daemon.info ...) and stderr to another (logger -p daemon.err ...).

Is that possible?

Thanks!
 
good suggestion

That's a good suggestion which I found to be useful too!

Unfortunately, current Bash implementation doesn't have this functionality. Moreover, no current operating system can do this so far from what I know.

Here I am proposing to the entire Linux community that OS designer should do this:
the stdio's pipe operator '|' should work the same as '>', and should support multi-pipe,

for example,
Code:
MyProgramA 1>A_stdout.txt 2>A_stderr.txt 1>A_stdout2.txt 2>B_stderr2.txt 1|MyProgramB 1|MyProgramC 2|MyProgramD

the standard output from MyProgramA is written into 2 files A_stdout.txt and A_stdout2.txt , in addition, it's piped into MyProgramB and MyProgramC, its error output is piped into MyProgramD

However, one problem of this design is that if there are multiple '|'s, there'll be ambiguity on the 2nd '|', i.e. do you want to pipe the stdout/err from the 1st program or the 2nd program? Maybe we can bracket them i.e.
Code:
MyProgramA 1|(MyProgramB 1>B.stdout 2>B.stderr) 2|(MyProgramC 1>C.stdout 2>C.stderr)

Xuancong
 
What linux community are you referring to? Why would a FreeBSD forum give a a rat's arse about it? Are you high? This is FreeBSD, not linux.
 
Back
Top