Adam S
Adam S

Reputation: 9235

Redirecting output from an executable, but not all output is redirected?

I am experiencing an issue whereby I cannot completely redirect output from an executable. For discussion, let's say the executable is printnames.exe.

If I do printnames.exe (without redirection), the following output is displayed in the command window:

Adam
Tim
Jesse
Sean

However if I do printnames.exe > myfile.txt, the command window shows:

Tim
Sean

...and the contents of myfile.txt is:

Adam
Jesse

How is this possible? What in the code can cause such behavior? Shouldn't the redirection operator redirect all output?

Upvotes: 1

Views: 124

Answers (1)

S.Lott
S.Lott

Reputation: 391854

How is this possible?

You have two output streams.

What in the code can cause such behavior?

Writing to standard output and also writing to standard error.

Shouldn't the redirection operator redirect all output?

No. Default redirection applies to standard output.

Use 2> to redirect standard error.


http://www.gnu.org/software/bash/manual/bashref.html#Redirections

Upvotes: 5

Related Questions