zsh-users
 help / color / mirror / code / Atom feed
* how to pipe to stdout and stderr
@ 2003-12-18  0:12 Andy Spiegl
  2003-12-18  1:44 ` Ibraheem Umaru-Mohammed
  2003-12-18  2:13 ` Dan Nelson
  0 siblings, 2 replies; 7+ messages in thread
From: Andy Spiegl @ 2003-12-18  0:12 UTC (permalink / raw)
  To: ZSH User List

Maybe I'm just too tired right now, but I can't find the solution how to
pipe the standard output and standard error to 2 different programs.

Example:
 program foo   (prints to stdout and stderr)
  program bar1 should receive only stdout
  program bar2 should receive only stderr

How can I do this?  Someone knows how to do that in bash, too?

Thanks so much,
 Andy.

-- 
           http://peru.spiegl.de  Our project
      http://radiomaranon.org.pe  Radio Marañón, Jaén, Perú
                              o      _     _         _
  ------- __o       __o      /\_   _ \\o  (_)\__/o  (_)          -o)
  ----- _`\<,_    _`\<,_    _>(_) (_)/<_    \_| \   _|/' \/       /\\
  ---- (_)/ (_)  (_)/ (_)  (_)        (_)   (_)    (_)'  _\o_    _\_v
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 If you can't write your ideas on the back of my calling card,
 you don't have a clear idea.  -- David Belasco


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: how to pipe to stdout and stderr
  2003-12-18  0:12 how to pipe to stdout and stderr Andy Spiegl
@ 2003-12-18  1:44 ` Ibraheem Umaru-Mohammed
  2003-12-18  2:01   ` Andy Spiegl
  2003-12-18  2:13 ` Dan Nelson
  1 sibling, 1 reply; 7+ messages in thread
From: Ibraheem Umaru-Mohammed @ 2003-12-18  1:44 UTC (permalink / raw)
  To: Andy Spiegl; +Cc: ZSH User List

On Thu, 2003-12-18 at 00:12, Andy Spiegl wrote:
> Maybe I'm just too tired right now, but I can't find the solution how to
> pipe the standard output and standard error to 2 different programs.
> 
> Example:
>  program foo   (prints to stdout and stderr)
>   program bar1 should receive only stdout
>   program bar2 should receive only stderr
> 
> How can I do this?  Someone knows how to do that in bash, too?
[...]
<ibraheem@umarumohammed:~/try> ls
<ibraheem@umarumohammed:~/try> touch foo
<ibraheem@umarumohammed:~/try> ls foo bar
ls: bar: No such file or directory
foo
<ibraheem@umarumohammed:~/try> ls foo bar > stdout 2> stderr
<ibraheem@umarumohammed:~/try> cat stdout 
foo
<ibraheem@umarumohammed:~/try> cat stderr 
ls: bar: No such file or directory
[...]

HTH,

			--ibz.


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: how to pipe to stdout and stderr
  2003-12-18  1:44 ` Ibraheem Umaru-Mohammed
@ 2003-12-18  2:01   ` Andy Spiegl
  2003-12-18  2:17     ` Hisham Muhammad
  2003-12-18  9:59     ` Ibraheem Umaru-Mohammed
  0 siblings, 2 replies; 7+ messages in thread
From: Andy Spiegl @ 2003-12-18  2:01 UTC (permalink / raw)
  To: ZSH User List

> <ibraheem@umarumohammed:~/try> ls foo bar > stdout 2> stderr

Thanks, but I don't want to redirect to 2 files, but pipe to 2 programs.
 Andy.

-- 
           http://peru.spiegl.de  Our project
      http://radiomaranon.org.pe  Radio Marañón, Jaén, Perú
                              o      _     _         _
  ------- __o       __o      /\_   _ \\o  (_)\__/o  (_)          -o)
  ----- _`\<,_    _`\<,_    _>(_) (_)/<_    \_| \   _|/' \/       /\\
  ---- (_)/ (_)  (_)/ (_)  (_)        (_)   (_)    (_)'  _\o_    _\_v
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 Ever wonder about those people who spend $2.00 a piece on those little
 bottles of Evian water?  Try spelling Evian backwards: NAIVE
    (George Carlin, US comedian)


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: how to pipe to stdout and stderr
  2003-12-18  0:12 how to pipe to stdout and stderr Andy Spiegl
  2003-12-18  1:44 ` Ibraheem Umaru-Mohammed
@ 2003-12-18  2:13 ` Dan Nelson
  2003-12-18 10:17   ` Andy Spiegl
  1 sibling, 1 reply; 7+ messages in thread
From: Dan Nelson @ 2003-12-18  2:13 UTC (permalink / raw)
  To: ZSH User List

In the last episode (Dec 18), Andy Spiegl said:
> Maybe I'm just too tired right now, but I can't find the solution how to
> pipe the standard output and standard error to 2 different programs.
> 
> Example:
>  program foo   (prints to stdout and stderr)
>   program bar1 should receive only stdout
>   program bar2 should receive only stderr
> 
> How can I do this?  Someone knows how to do that in bash, too?

It's a little tricky since regular pipes are linear.  Zsh does let you
redirect to commands though:

% ( echo stdout ; echo 1>&2 stderr ) > >(tr a-z A-Z) 2> >(tr a-z b-za)
tuefss
STDOUT
%

See the zsh manpage, under the heading "PROCESS SUBSTITUTION".

-- 
	Dan Nelson
	dnelson@allantgroup.com


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: how to pipe to stdout and stderr
  2003-12-18  2:01   ` Andy Spiegl
@ 2003-12-18  2:17     ` Hisham Muhammad
  2003-12-18  9:59     ` Ibraheem Umaru-Mohammed
  1 sibling, 0 replies; 7+ messages in thread
From: Hisham Muhammad @ 2003-12-18  2:17 UTC (permalink / raw)
  To: Andy Spiegl, ZSH User List

On Thursday 18 December 2003 00:01, Andy Spiegl wrote:
> > <ibraheem@umarumohammed:~/try> ls foo bar > stdout 2> stderr
>
> Thanks, but I don't want to redirect to 2 files, but pipe to 2 programs.

Use mkfifo, maybe?

hisham@aria ~/test] mkfifo err
hisham@aria ~/test] mkfifo out

hisham@aria ~/test] cat out | tac > out.txt &
hisham@aria ~/test] cat err | tr '[:lower:]' '[:upper:]' > err.txt &
hisham@aria ~/test] ls * zzz > out 2> err

hisham@aria ~/test]cat err.txt
LS: ZZZ: NO SUCH FILE OR DIRECTORY

hisham@aria ~/test] ls -1
err
err.txt
out
out.txt

hisham@aria ~/test] cat out.txt
out.txt
out
err.txt
err

-- 
Hisham Muhammad
"...and this is the first step."


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: how to pipe to stdout and stderr
  2003-12-18  2:01   ` Andy Spiegl
  2003-12-18  2:17     ` Hisham Muhammad
@ 2003-12-18  9:59     ` Ibraheem Umaru-Mohammed
  1 sibling, 0 replies; 7+ messages in thread
From: Ibraheem Umaru-Mohammed @ 2003-12-18  9:59 UTC (permalink / raw)
  To: ZSH User List

On [18/12/03 03:01 +0100], Andy Spiegl wrote:
> > <ibraheem@umarumohammed:~/try> ls foo bar > stdout 2> stderr
> 
> Thanks, but I don't want to redirect to 2 files, but pipe to 2 programs.
>  Andy.

Right, I get ya. Does this help:

[...]
<ibraheem@umarumohammed:~/try> ls
<ibraheem@umarumohammed:~/try> touch foo
<ibraheem@umarumohammed:~/try> ls
foo
<ibraheem@umarumohammed:~/try> ls foo bar >>(cat > stdout) 2>>(cat > stderr)
<ibraheem@umarumohammed:~/try> ls
foo	stderr	stdout
<ibraheem@umarumohammed:~/try> cat stdout
foo
<ibraheem@umarumohammed:~/try> cat stderr
ls: bar: No such file or directory
[...]


HTH,

			--ibz.
-- 


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: how to pipe to stdout and stderr
  2003-12-18  2:13 ` Dan Nelson
@ 2003-12-18 10:17   ` Andy Spiegl
  0 siblings, 0 replies; 7+ messages in thread
From: Andy Spiegl @ 2003-12-18 10:17 UTC (permalink / raw)
  To: ZSH User List

Thanks guys!
 Andy.

-- 
           http://peru.spiegl.de  Our project
      http://radiomaranon.org.pe  Radio Marañón, Jaén, Perú
                              o      _     _         _
  ------- __o       __o      /\_   _ \\o  (_)\__/o  (_)          -o)
  ----- _`\<,_    _`\<,_    _>(_) (_)/<_    \_| \   _|/' \/       /\\
  ---- (_)/ (_)  (_)/ (_)  (_)        (_)   (_)    (_)'  _\o_    _\_v
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 "In a cat's eye, all things belong to cats."  --English proverb


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2003-12-18 10:20 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-12-18  0:12 how to pipe to stdout and stderr Andy Spiegl
2003-12-18  1:44 ` Ibraheem Umaru-Mohammed
2003-12-18  2:01   ` Andy Spiegl
2003-12-18  2:17     ` Hisham Muhammad
2003-12-18  9:59     ` Ibraheem Umaru-Mohammed
2003-12-18  2:13 ` Dan Nelson
2003-12-18 10:17   ` Andy Spiegl

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).