2

tee is a slick little utility that allows piping output to a file as well as stdout (the console). Windows ports for tee exist (wintee, gnuwin32's tee, etc), but all the ones I've tried have the same issue as GNU tee; that is, tee eats the return code from whatever process is piped to it.

For linux, there are various ways to get that return code back (http://lists.samba.org/archive/linux/2004-March/010158.html). How can I get that return code back in windows?

NOTE: I don't want tee's return code (which is usually zero), I want the return code from the process piped to tee.

3
  • Did you try reading %ERRORLEVEL% right after running the command?
    – jftuga
    Commented Jun 6, 2012 at 21:44
  • @jftuga Yes, of course. The problem is that tee doesn't propagate the errorlevel of the process piped to it - it replaces errorlevel with its own.
    – Pat
    Commented Jun 7, 2012 at 15:28
  • Uh, NO process propagates the errorlevel [sic] of the process piped to it, kinda the way pipes work. If a program upstream fails, the pipe fails. If you wanted to output the errorlevel of an upstream program, you could use (./prog1; echo $ERRORLEVEL >/dev/stderr) | tee out1 This would send the prog1 errorlevel to stderr to be captured and read by something... although it's a kludge, and won't work on Windows machines. Basically, tee has never passed on anything BUT stdout... you're not missing anything, it's supposed to be that way. You could always write your own. Easy enough.
    – lornix
    Commented Jun 30, 2012 at 7:05

0

You must log in to answer this question.

Browse other questions tagged .