Re: Redirecting compiler output

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Jan 30, 2004 at 11:42:22AM -0600, "Dr. Germund Höjer" wrote:
> I cannot get g77 and gcc to redirect compiler messages to a text file.
> The line
> 
> g77 code.f > report.txt
> 
> only creates a file report.txt of zero lenght and any error or warning 
> messages from the compiler only scroll by on the screen. I get the same 
> behaviour working in KDE graphic mode and in plain text mode (SuSE Linux 
> 8.1) with various versions of gcc. I am using 3.3.2 now.
> And the same happens with gcc 3.2.2 running under MinGW/Windows98 so I 
> doubt it is an OS problem.
> 
> I have not found any clue in the gcc manuals.

That's because this has nothing to do with GCC. Errors and warnings of
programs are usually sent to the standard error stream (stderr). You
just redirected the standard output (stdout) to some file and hence
there was no "normal" output the file was empty.

Now, actually  this depends  on the shell  you're using --  you should
read its manual. If you happen to use bash, just use

g77 code.f 2> report.txt

to redirect stderr to that file or e.g.

g77 code.f &> report.txt

to redirect both stderr and stdout to that file.

HTH
-- 
Claudio Bley                                 ASCII ribbon campaign (")
Debian GNU/Linux user                         - against HTML email  X 
http://www.cs.uni-magdeburg.de/~bley/                     & vCards / \

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux