批处理脚本:保存stdout和在控制台输出过 [英] Batch script: save stdout and have the output in the console too

查看:644
本文介绍了批处理脚本:保存stdout和在控制台输出过的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在默认情况下的命令行程序的输出在控制台窗口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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆