Answer the question
In order to leave comments, you need to log in
Redirecting STDERR and STDOUT to different scripts on STDIN?
Hello, actually the question is in the title, I can not google it.
Answer the question
In order to leave comments, you need to log in
Found a solution via overriding streams:
{ command1 2>&3 | command2; } 3>&1 1>&2 | command3
From here: stackoverflow.com/questions/9112979/pipe-stdout-and-stderr-to-two-different-processes-in-shell-script
You can, for example, create named pipes (google: mkfifo).
Let's make a test program test_redir.c with the following content:
#include <stdio.h>
int main()
{
fprintf(stdout,"Test STDOUT\n");
fprintf(stderr,"Test STDERR\n");
return 0;
}
Collected, prepared for launch.
$ gcc test_redir.c -o test_redir
$ chmod +x test_redir
Now let's create the pipes: Let 's run
Now, in two new terminals, let's see what's in the pipes:
This is a bad example, so in the first terminal, the output will appear only after we see what's in the test_err pipe, but the idea should be clear
$ mkfifo test_out
$ mkfifo test_err
.
$ ./test_redir 1>test_out 2>test_err
$ cat tmp/test_out
Test STDOUT
$ cat tmp/test_err
Test STDERR
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question