Thanks (an no it's not for school).
-- 
Linux Home Automation         Neil Cherry       nch...@linuxha.com
http://www.linuxha.com/                         Main site
http://linuxha.blogspot.com/                    My HA Blog
Author of:    	Linux Smart Homes For Dummies
> I've found name pipes (fifos) but I am confused on using them
> properly. What I want to do is to take the stdout of a process and
> send it to another process to be filtered. I also want to take the
> stderr of the first process and send it to another process to
> also be filtered. Any examples?
> 
> Thanks (an no it's not for school).
>
Maybe this simple example will help.  I will create two named pipes. 
Then I will in the background, cat these pipes to files.  Next I will
create a file named "afile".  To make it all happen I do a directory
listing of afile and notafile (notafile does not exist and should give an
error) and redirect the output to the named pipes.  Finally I will cat out
the files with the data that the background cats read from the fifos. 
First a cut and paste of my terminal, following is a breakdown of what
happens.
$ mkfifo stderrpipe
$ mkfifo stdoutpipe
$ cat stderrpipe > errorlog &
[1] 5860
$ cat stdoutpipe > outlog &
[2] 5863
$ touch afile
$ ls afile notafile > stdoutpipe 2> stderrpipe 
[1]-  Done                    cat stderrpipe > errorlog
[2]+  Done                    cat stdoutpipe > outlog
$ cat errorlog 
ls: notafile: No such file or directory
$ cat outlog 
afile
DEEPER EXPLANATIONS FOLLOW
                       CREATE PIPE FOR ERROR
$ mkfifo stderrpipe 
                       CREATE PIPE FOR STDOUT
$ mkfifo stdoutpipe 
                       CAT THE ERROR PIPE TO A FILE IN BACKGROUND
$ cat stderrpipe > errorlog &
              	       BACKGROUND PROCESS #1
[1] 5860 
                       CAT THE STDOUT PIPE TO A FILE IN BACKGROUND
$ cat stdoutpipe > outlog &
                       BACKGROUND PROCESS #2
[2] 5863 
                       CREATE A FILE "afile"
$ touch afile
                       REDIRECT THE OUTPUT OF ls TO THE PIPES
$ ls afile notafile > stdoutpipe 2> stderrpipe
                       BOTH BACKGROUND PROCESSES FINISH WHEN THEIR 
                       PIPES GET TO END OF FILE.  THAT IS NOW, BECAUSE
                       THE LS COMMAND IS FINISHED GIVING THEM DATA
[1]-  Done                    cat stderrpipe > errorlog
[2]+  Done                    cat stdoutpipe > outlog
                       OUTPUT THE FILES CREATED BY THE ABOVE cats
$ cat errorlog
ls: notafile: No such file or directory
$ cat outlog
afile
I hope that helps.
stonerfish
No need for named pipes here.
{
  {
    cm1 3>&- |
      cmd2 2>&3 3>&-
  } 2>&1 >&4 4>&- |
    cmd3 3>&- 4>&-
} 3>&2 4>&1
-- 
Stéphane
Thanks! That helps big time.
Thanks.
OK now I see why I didn't get it to work. I didn't try that far.
But I have to say I'm not quite sure what I'm reading just yet.
I'll have to hit the man pages as I'm not used to the >&-
syntax.
N>&- close the file descriptor with number N.
Janis
>
> --
> Linux Home Automation         Neil Cherry       nche...@linuxha.comhttp://www.linuxha.com/                        Main sitehttp://linuxha.blogspot.com/                   My HA Blog
3>&- is for closing fd 3. It's not necessary, but it's for tidy
up. None of the commands will ever try (not should they) to
access the fd 3 and 4, so it's best to close them before
executing those commands so that they can use those fds for
something else. 
{
  {
    cm1 |
      cmd2 2>&3
  } 2>&1 >&4 |
    cmd3
} 3>&2 4>&1
is functionnaly equivalent.
if cmd2 doesn't output anything on its stdout nor stderr, it can
even be simplified to:
{ cm1 | cmd2; } 2>&1 | cmd3
Or if you want to be sure:
{ cm1 | cmd2 > /dev/null 2>&1; } 2>&1 | cmd3
-- 
Stéphane
Thanks that helps. :-)