Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Is there a way in Windows 7 cmd shell to redirect the stderr to stdout while keeping the stderr stream intact?

For example, I have a program that outputs to stderr and stdout the following message

TO STDOUT  
TO STDERR

I want to have two files stderr.txt and stdout.txt with the following content

stderr.txt
TO STDERR

stdout.txt
TO STDOUT
TO STDERR

Is this possible?

share|improve this question
add comment

1 Answer

I think this is what you want:

dir a.txt > output.msg 2> output.err >&1

or

dir 1>a.txt 2>&1 | type a.txt

2> redirects stderr &1 sends stderr back to stderr.

I'd have to test these to give you a better answer

share|improve this answer
    
The first is not working. The second redirects stderr to stdout but does not give stderr alone. –  Stecy Jul 20 '12 at 15:48
    
may need to use a tee clone. The tricky part is that you want 2 copies of stderr. Pity you are stuck in the legacy prompt. –  Jim B Jul 20 '12 at 17:12
add comment

Your Answer

 
discard

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.