I think we should try putting the lid back on this particular can of
worms before it's too late.
The syntax
batchfile >reportfile 2>&1
as Tom originally proposed /should/ work AND, as Tom also said,
batchfile 1>reportfile 2>&1
should yield identical results.
What I was pointing out was that
batchfile 2>&1 >reportfile
or
batchfile 2>&1 1>reportfile
would NOT yield the same results; the "2>&1" would appear to be ignored.
This violates the accepted principle that the order of switches is
irrelevant (and true, this is redirection, not switches - but it is data
delivered to the SHELL itself for control of the job rather than the
process to be controlled.)
The
batchfile >reportfile 2>&1 >anotherfile
syntax is simply a discussion point. Personally, I'd have produced an
error because it is ambiguous as to the destination of the redirection.
===============
In the case of OP's problem, I'd say
batchfile >reportfile 2>errorfile
which should be equivalent to
batchfile 1>reportfile 2>errorfile
will show which report lines are sent to which device and that any OTHER
report lines appearing would be being sent by the process to CON: rather
than STDOUT or STDERR; hence they may be difficult or impossible to capture.
================
On the subject of output to CON: - ISTR some utilities bypass
STDOUT/STDERR as I've outlined - but their identities escape me. There
are also MS-supplied utilities that produce the sequence
[spaces]text[CR]text[CR][LF]
where the second text overwrites the leading spaces - but FOR/F uses
[CR] as the line-terminator...
Which is getting off the subject a little.
Has anybody noticed the warning/suggestion about speed that occasionally
appears when a big file is used as SORT input in a
SORT <bigfile >newfile
command? I've seen no pattern - repeating PRECISELY the same command
does not necessarily produce the message. I've an idea that that message
(unless it's a figment of my imagination) is sent to CON:
===========================
And for the sake of demonstrating the flakiness of the
redirection-sequence-sensitivity that triggered this part of the
discussion, try this quick quiz:
@ECHO OFF
DIR \idontexist
DIR \idontexist >u:\1-1.txt
DIR \idontexist >u:\2-1.txt 2>2-2.txt
DIR \idontexist 2>3-2.txt
DIR \idontexist 1>u:\4-1.txt
DIR \idontexist 1>u:\5-1.txt 2>5-2.txt
DIR \idontexist 2>6-2.txt >u:\6-1.txt
DIR \idontexist 2>u:\7-2.txt 1>7-1.txt
And here's the result:
Volume in drive U has no label.
Volume Serial Number is 0422-0000
Directory of u:\
24/08/2012 16:32 93 1-1.txt
24/08/2012 16:32 93 2-1.txt
24/08/2012 16:32 93 4-1.txt
24/08/2012 16:32 93 5-1.txt
24/08/2012 16:32 93 6-1.txt
24/08/2012 16:32 16 7-2.txt
6 File(s) 481 bytes
0 Dir(s) 2,114,617,344 bytes free
?-1.txt are all identical.
How come 7-2.txt is created but 5-2.txt isn't?
(7-2.txt contains
File not found
)
====================
Be thankful I stopped the investigation there. It was going to be the
first step to investigating all of the sequence combinations of
>file.txt
1>file1.txt
2>file2.txt
1>&2
2>&1
...