Advertisement

Redirecting output

Started by February 22, 2006 06:10 AM
1 comment, last by markr 18 years, 8 months ago
I'm trying to capture the output of gcc in a script. Currently I can capture stdout, stderr or both, but when I capture both the output is jumbled. (all of one stream, then all of the other). What I'd really like is the interleaved output. Any ideas?
I'm assuming you mean you're trying to redirect diagnostic output from the compiler into a file.

I have never had a problem with the compiler writing to stdout, since it generally doesn't. All of its diagnostic output goes to stderr. I've never had jumbled or interleaved output (from the compiler. I work with multithreaded apps daily, believe me I know jumbled output).

Can you give more details on what you're trying to do?

Stephen M. Webb
Professional Free Software Developer

Advertisement
Perhaps you can direct them both to the same file descriptor, rather than just appending them to the same file (which will open two descriptors), like:

g++ something... >compiler_errs.txt 2>&1


The 2>&1 tells it to make stderr a duplicate of stdout.

Mark

This topic is closed to new replies.

Advertisement