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"."
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.