Basic question about stderr
chaseratx via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Sat May 21 14:47:20 PDT 2016
On Saturday, 21 May 2016 at 21:40:36 UTC, Era Scarecrow wrote:
> On Saturday, 21 May 2016 at 21:21:31 UTC, chaseratx wrote:
>> I'm learning D and I have a basic question.
>>
>> I'm trying to write stderr to a file using open() (rather than
>> shell piping/redirection). It works for stdout but doesn't
>> seem to work with stderr.
>>
>> http://pastebin.com/KgzR9wAF
>>
>> stdout is written to the file, but stderr is not and outputs
>> to the shell. I'm not sure why. I Googled but couldn't find
>> an answer. Any hints?
>
> // <= causes range violation, might use foreach instead
> while (i < numbers.length) {
> write(numbers[i], " ");
> stderr.write(numbers[i]*10); //force stderr, 10x to
> differentiate output
>
> with (stderr) { //also force stderr
> write(" ");
> }
Thanks Era, but I am not trying to fix the range error. That was
put there intentionally to create stderr output. I'm trying to
figure out how to get ALL stderr output directed to a file the
same as if I had used a "2>error.log" redirect from the command
line.
More information about the Digitalmars-d-learn
mailing list