0

I have a project, which builds by using make, and I want to add possibility to analyze overall state of warning messages.

My idea is change make rules in order to duplicate stderr compilation output into separate file during full rebuild. Means each time make all will be done, all output will be printed in console and in addition stderr output will be duplicating into separate file.

This warning report file will be added into repository, so that I will have possibility to compare warnings existing in repository and local warnings.

The question is how to DUPLICATE (not redirect) stderr output into separate file? Means how I should change all target in Makefile?

I know how to redirect stderr output (make all 2>warning_report.txt), but it is not what I need. Warning messages should be both in main console output and in warning file.

I use Windows 7 as work environment but I had no any deal with Windows command line or batch files before.

Thanks in advance.

Edited:

In my case final solution looks like below:

make all 3>&1 1>&2- 2>&3- | tee.bat warning_report.txt

In this case script tee.bat, which is written in JScript for Windows, I took from link specified by PA (thanks).

What about swapping, I took it from here and here.

Philzen
  • 3,945
  • 30
  • 46
yurko
  • 623
  • 1
  • 7
  • 21
  • see this previous question at SO http://stackoverflow.com/questions/10711839/using-a-custom-tee-command-for-bat-file/10719322#10719322 – PA. Mar 07 '13 at 13:26
  • Why don't you just redirect it to a file and then display the files contents? – BDM Mar 07 '13 at 21:27
  • Because compile time of whole project is approximately 5 minutes. – yurko Mar 07 '13 at 21:48
  • Just curious, what does the compile time have to do with my comment? – BDM Mar 08 '13 at 06:05

2 Answers2

0

I don't know about windows but you can do it using tee command in Linux. tee is used to redirect STDOUT to file as well as console so you can take its advantage and check if you can solve your problem.

make all 2>&1 1>stdout.log | tee stderr.log

redirect STDERR to STDOUT, redirect STDOUT to stdout.log and all the STDERR is copied to stderr.log ans echoed on the console as well.

But the solution is not complete yet. The STDOUT is not printed on the console but only copied to the stdout.log. Try playing around the commands you will get the solution .

Sagar Sakre
  • 2,336
  • 22
  • 31
0

I just re-read your question and decided I would try to answer it.

Here's a snippet made to export stderr and display it.

@echo off
if exist stderr.error del stderr.error
this_is_not_a_command 2>stderr.error
if exist stderr.error type stderr.error & del stderr.error

This would export stderr to a file and then display the contents of that file.

Hope that helps.

BDM
  • 3,760
  • 3
  • 19
  • 27
  • Thank you for your help. As now I have no access to my PC, I can't try this now. I will try in Monday. – yurko Mar 08 '13 at 22:37
  • How did it go? Does it help? – BDM Mar 12 '13 at 10:42
  • I had tried to use this but eventually I used solution explained above (see section **edited** [above](http://stackoverflow.com/q/15267261/1039412)). – yurko Mar 12 '13 at 11:03