Tuesday 27 August 2019

command line - Displaying and storing Windows Batch file output


I've got a batch file written that runs a program we've developped, passing in a number of parameters. Whilst running the program in debug mode, a large number of debug messages are output, which it would be handy to review later, although I still want to be able to see the program running "live" as it were, within the cmd.exe window.


In a *nix environment I could use Tee to output to both the text file and stdout. Any suggestions?



Answer



TEE for Windows
TEE enables you to redirect standard output to a file and display it on screen simultaneously.


some_program | TEE [ /D:nn ] file_name

Available as BAT, Perl and Regina scripts.


Author's note.



The Rexx and Perl scripts will start displaying the result immediately. For the batch file, what it boils down to is, you may just as well redirect the command's output to a file and then display that file afterwards. As a bonus, that way you won't skip empty lines.


Note: These scripts were written just for fun. Even though the do work, they cannot compete with the "real" stuff -- compiled executables, written in "true" programming languages by true programmers.





I use Cygwin.
There is also Tee utility for Windows updated


No comments:

Post a Comment

How can I VLOOKUP in multiple Excel documents?

I am trying to VLOOKUP reference data with around 400 seperate Excel files. Is it possible to do this in a quick way rather than doing it m...