I want to run an ANT script which prompts the user for input, so it needs to be interactive through the console. at the same time I want to log the console content to a log file. I know I can use ant >build.log 2<&1
which will redirect to file, but leave the console empty.
So, how can that be done? needed on windows and unix.
To redirect the output of a command to a file, type the command, specify the > or the >> operator, and then provide the path to a file you want to the output redirected to. For example, the ls command lists the files and folders in the current directory.
Redirecting stdout and stderr to a file: The I/O streams can be redirected by putting the n> operator in use, where n is the file descriptor number. For redirecting stdout, we use “1>” and for stderr, “2>” is added as an operator.
Redirecting output to a single file and screen: You can also append the redirected output by utilizing the “-a” or “–append” option with the tee command. -a or –append option allows tee command to append files rather than overwriting the file's content.
Use tee
.
ant 2>&1|tee build.log
tee.exe is also available for Windows from http://unxutils.sourceforge.net/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With