无法重定向输出消息在Windows命令提示符(cmd.exe) [英] unable to redirect output message in windows command prompt (cmd.exe)

查看:1079
本文介绍了无法重定向输出消息在Windows命令提示符(cmd.exe)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试在Windows命令提示符下运行以下命令。

  abc.exe> log.txt 2>& 1 
pre>

我期望 abc.exe 的所有输出被定向到 log .txt ,但它不工作,因为 log.txt 为空。



但是,如果我只是执行 abc.exe ,输出会显示在Windows命令提示符下。



我不知道什么是这个应用程序(STDOUT或STDERR)使用的输出处理程序,但我想知道是否有一种方法来捕获所有的消息,而不管处理程序。

解决方案

重定向到文件时控制台输出不可见的症状可能是由于缺少 flush()写入标准输出的程序。但是,当程序退出(正常)或相应缓冲区填满并自动刷新时,输出应可见。


I tried to run the following command in Windows command prompt.

abc.exe >log.txt 2>&1

I'm expecting all output from abc.exe to be directed to log.txt, but it doesn't work, as the log.txt is empty.

However, if I just execute abc.exe, the output is showing up in Windows command prompt.

I'm not sure what is the output handler used by this application (STDOUT or STDERR), but I'm wondering is there a way to capture all messages regardless of the handler.

解决方案

The symptom that console output is not visible when redirected to a file can be due to a missing flush() in the program that writes to the standard output. However, the output should be visible when the program exits (gracefully) or when the respective buffer fills up and is flushed automatically.

这篇关于无法重定向输出消息在Windows命令提示符(cmd.exe)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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