laziness, impatience, and hubris | |
PerlMonks |
Re: How to tee STDERR on Windowsby Marshall (Canon) |
on Jan 13, 2022 at 08:15 UTC ( [id://11140420]=note: print w/replies, xml ) | Need Help?? |
Interesting question. Windows supports redirection of STDERR and STDOUT, like test.pl >log 2>&1 will send both to a file. "tee" is available in the powershell. just typing "powershell" at the windows cmd prompt will start the powershell. But the problem is that there is no easy way to pipe STDERR into another program like tee. You can tee STDOUT and send STDERR to a file, but you want both on the screen and in the file. This is one heck of an ugly Win10 command line solution. But I tested this on my machine and it does work. I admit that I am still struggling to understand exactly why it works. I make no claims other than I did test this on Win10 home edition with an actual Perl program. Win10prompt>for /f "delims=" %L in ('perl testchompwhile.pl 2^>^&1') do @echo %L & echo %L >> log I happened to have a short Perl program that I wrote for another post for testing. This appends both STDERR and STDOUT to log and of course the also both go to screen as requested. update: The only other info I have about this is: "The for command iterates over the output lines of the script. The carets escape the characters that follow them. The first echo goes to the screen and the second is appended to the file named "log"."
In Section
Seekers of Perl Wisdom
|
|