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.
> 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.
-bruce
--
Bruce Payette [MSFT]
Windows PowerShell Technical Lead
Microsoft Corporation
This posting is provided "AS IS" with no warranties, and confers no rights.
Visit the Windows PowerShell Team blog at:
http://blogs.msdn.com/PowerShell
Visit the Windows PowerShell ScriptCenter at:
http://www.microsoft.com/technet/scr.../hubs/msh.mspx
My Book:
http://manning.com/powershell
"Olav Kindt" <kindt@broadpark.no.spam> wrote in message
news:%23OB5NQ6%23GHA.4524@TK2MSFTNGP04.phx.gbl...
> All,
>
> I know this has been debated before, but I have searched the old postings
> and not found it, so I try to start a new thread on this issue.
>
> I have a legacy application for testing that will write some of its output
> to stdout, and some to stderr. I would like to capture the output from
> this application so that I can parse the output for the result.
>
> The DOS command for doing this is :
>
> mytest1.exe > test_result.txt 2>&1
> mytest2.exe >> test_result.txt 2>&1
>
> Can this be done directly in Powershell??
>
> I have also tried to do
>
> function all_tests {
> cmd /c "mytest1.exe > test_result.txt 2>&1"
> ...
>
> }
>
> 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
> One or more CON code pages invalid for given keyboard code
> File not found.
> PS>
>
> Can anyone explain to me what this means. Running the command from the
> Powershell command line seems to work OK, I only get these messages when
> running from a script file.
>
>
> Hope someone out there can help me
>
> Thanks
>
> Olav