How to redirect console output to file and STILL g

2019-03-10 23:50发布

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.

2条回答
成全新的幸福
2楼-- · 2019-03-11 00:07

Use tee.

ant 2>&1|tee build.log

tee.exe is also available for Windows from http://unxutils.sourceforge.net/

查看更多
男人必须洒脱
3楼-- · 2019-03-11 00:07

You can use tee.

Example:

$ echo "Hello, world" | tee /tmp/outfile
Hello, world
$ cat /tmp/outfile
Hello, world

tee writes its stdin to both stdout as well as one or more files given on the command line.

查看更多
登录 后发表回答