批处理脚本:保存stdout和在控制台输出过 [英] Batch script: save stdout and have the output in the console too
问题描述
在默认情况下的命令行程序的输出在控制台窗口psented $ P $和我都知道,使用>
或>>
我们可以重新wrire /标准输出追加到一个外部文件,但如果在命令行应用程序没有内部日志记录功能,以保存输出内容。我想要的标准输出既在控制台和被保存在一个外部文件。这样的事情可能吗?
By default the output of commandline applications is presented in console window and I know that using >
or >>
we can re-wrire/append the stdout to an external file but what if the commandline application doesn't have internal logging facility to save the output. I want the stdout to be both in the console and be saved in an external file. Is such a thing possible?
推荐答案
尝试是这样的:
@echo off
echo hello > log.txt & type log.txt
pause
但是使用这个你只能在日志文件一个命令输出的一次。你可以用它试试>方式>
但是,你得到的所有命令的每次使用这个时候输出
But using this you can only have one command-output in the log-file at once. You could try it with >>
but that way you get the outputs of all commands every time you use this.
这篇关于批处理脚本:保存stdout和在控制台输出过的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!