|
Re: Redirection of standard out and standard error Bruce Payette [MSFT] wrote:
> The commands
>
> mytest1.exe > test_result.txt 2>&1
> mytest2.exe >> test_result.txt 2>&1
>
> should work fine in PowerShell as the redirection operators are the same.
But they don't seem to work as expected. For testing purpose I have made
a simple program that write one line to stdout, and one line to stderr.
This is what I get when running it:
PROMPT> .\hello.exe
Hello STDOUT!
Hello STDERR!
When I do this:
PS PROMPT> .\hello.exe > mylog 2>&1
PS PROMPT> more mylog
Hello STDOUT!
hello.exe : Hello STDERR!
At line:1 char:12
+ .\hello.exe <<<< > mylog 2>&1
PS PROMPT>
As you can see the content of the file is not what I would expect.
When running the same command in a DOS shell it works fine.
>> When I dot source this file, and call the all_tests function, it hangs,
>> and when looking at the output in the test_result.txt file i see this:
>>
>> PS> more test_result.txt
>
> From the above, somewhere in your all_tests function you're calling "more"
> which is probably why it appears to be hanging - more is waiting for input.
The line more test_result.txt is just the command I used to show the
output of the command that was hanging.
Olav |