Is there a way to redirect an output inside a windows .bat to a file AND to the sysout at the same time. At the moment I am using the answer from this question: "Is it possible to redirect the output of a batch file inside the script?" to redirect the output to a file, but i am using >> to append on the log-file if the process runs multiple times. The only problem is that i now get no ouput at sysout, which i also would like to have.
Asked
Active
Viewed 799 times
1 Answers
2
You need a tee
program, which does exactly what you want. It is standard on unix, but alas, not so on Windows.
There are free ports of unix utilities for windows from Gnu: http://gnuwin32.sourceforge.net/packages/coreutils.htm. Included is the tee
command.
Or you could use a simple hybrid JScript/batch TEE.BAT utility that I posted at https://stackoverflow.com/a/10719322/1012053.
Assuming TEE.BAT is in your current directory, or better yet, somewhere within your PATH, then:
yourCommand | tee "outpuFile.txt"