【问题标题】:Using DOS/CMD/batch files how can you show Console output, and redirect the STDOUT and STDERR streams to files?使用 DOS/CMD/批处理文件如何显示控制台输出,并将 STDOUT 和 STDERR 流重定向到文件?
【发布时间】:2009-10-30 21:38:56
【问题描述】:

直接控制台到 ok.log,例如错误到 error.log

【问题讨论】:

  • call C:\local\jboss.bat > %CTODAY%.jboss.log 2> %CTODAY%.err.jboss.log 只写入 jboss.log 而不是 err.jboss.log = /

标签: batch-file cmd stream dos


【解决方案1】:
[your command] > ok.log 2> error.log

【讨论】:

  • 我试过了,它只是写入文件并且不显示任何输出
  • amvx - 您确定要写入标准输出和标准错误,并且您确定您的 %CTODAY% 有效吗?因为如果我用 Python 来做,一切都会按预期进行。
【解决方案2】:

我发现这样做的唯一方法是使用UNIX tee command 的一些变体。你会像这样使用它:

[your command] 2> error.log | tee ok.log

【讨论】:

    【解决方案3】:

    好的,如果您的目标是将输出拆分为标准输出和文件,请查看this SO question

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-09-08
      • 2014-07-22
      • 2010-11-28
      • 1970-01-01
      • 2012-06-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多