Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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.

share|improve this question
    
Did you try reading %ERRORLEVEL% right after running the command? –  jftuga Jun 6 '12 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 Jun 7 '12 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 Jun 30 '12 at 7:05
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.