为什么我的机器将 stderr 写入 stdout? [英] Why is my machine writing stderr into stdout?

查看:41
本文介绍了为什么我的机器将 stderr 写入 stdout?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 C# 中针对 System.Diagnostics.Process 工具编写代码时,我只捕获 StandardOutput 并对其进行解析.但是,围绕此问题的单元测试在构建服务器上失败了.一位同事在他的机器上尝试后,也失败了.

While writing code against the System.Diagnostics.Process tools in C#, I was catching only StandardOutput and parsing it. However, a unit test around this failed on the build server. After a colleague tried on his machine, it failed as well.

然后我找到了 Jon Skeet 的回答关于为什么 StandardOutput 为空的问题,他提到同时捕获 StandardOutput 和 StandardError来自 System.Diagnostics.Process.果然,我们在同事的机器上试了一下,成功了.

Then I found Jon Skeet's answer to a question about why StandardOutput was empty, and he mentioned capturing both StandardOutput and StandardError from System.Diagnostics.Process. Sure enough, we tried that on my colleague's machine and it worked.

我的问题是,为什么在我的机器上写入 StandardOutput (stdout) 的内容被写入我同事机器和我们的构建服务器上的 StandardError (sterr)?是否有强制这种行为的环境设置?

My question is, why is something being written to the StandardOutput (stdout) on my machine that's being written to StandardError (sterr) on my colleague's machine and our build server? Is there an environment setting that forces this behavior?

推荐答案

事实证明我调用的命令 sqlcmd.exe 使用的是 SQL Server 2008 (c:\Program Files\Microsoft SQL Server\100\我同事的机器和构建机器上的 Tools\Binn) 版本,但我机器上的 SQL Server 2012 (c:\Program Files\Microsoft SQL Server\110\Tools\Binn) 版本.更改路径变量以指向我机器上的 SQL Server 2008 版本有效.

It turns out that the command I was calling, sqlcmd.exe, was using the SQL Server 2008 (c:\Program Files\Microsoft SQL Server\100\Tools\Binn) version on my colleague's machine and build machine, but the SQL Server 2012 (c:\Program Files\Microsoft SQL Server\110\Tools\Binn) version on my machine. Changing the path variable to point to the SQL Server 2008 version on my machine worked.

当您运行的 .sql 脚本比 sqlcmd.exe -t, 查询超时,参数设置为.

Maybe it will be of interest that the "Timeout expired" message is written to stdout instead of stderr in SQL Server 2012's sqlcmd.exe when the .sql script your running takes longer than the sqlcmd.exe -t, query timeout, parameter is set to.

这篇关于为什么我的机器将 stderr 写入 stdout?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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