LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   How to print 'make' error message to a file (https://www.linuxquestions.org/questions/linux-software-2/how-to-print-make-error-message-to-a-file-589412/)

olin 10-04-2007 10:41 AM

How to print 'make' error message to a file
 
I tried to compile beaver-0.3.0 but got many error messages while using 'make' command. I tried to diagnose the problem but I cannot scroll up the screen further enougth (even using rxvt) to see the first error. I tried to use make >> filename, or make -d >> filename. The former one only printed a few make info, and the latter one printed debug info other than error info. Could someone give me an idea? Thank you!

matthewg42 10-04-2007 10:51 AM

Programs which run the terminal have two output file handles - standard output and standard error, which have identifier numbers 1 and 2 respectively. "Normal" output customarily goes to standard output, and error messages and warnings typically go to standard error.

When you re-direct output using > or >>, this re-directs only standard output (the former truncating the target file first, the latter appending to the file).

In Borne style shells (including bash, which is a very common interactive shell on Linux systems), you can re-direct standard error using 2> and 2>>. For your purposes, you probably want to re-direct them both to the same file. You can do this by saying "2>&1", which means "take output on standard error and send it wherever standard output goes". This is how:
Code:

make > make_output 2>&1


All times are GMT -5. The time now is 07:25 AM.