如何捕获未发送到 stdout 的命令行文本?
我在项目中使用 LAME 命令行 mp3 编码器。我希望能够看到某人正在使用什么版本。如果我只是执行没有参数的 LAME.exe,例如:
C:\LAME>LAME.exe
LAME 32-bits version 3.98.2 (http://www.mp3dev.org/)
usage: blah blah
blah blah
C:\LAME>
如果我尝试使用 > 将输出重定向到文本文件对于文本文件,文本文件为空。在 c# 中使用 System.Process 运行该文本时,可以从哪里访问该文本?
I am using the LAME command line mp3 encoder in a project. I want to be able to see what version someone is using. if I just execute LAME.exe with no paramaters i get, for example:
C:\LAME>LAME.exe
LAME 32-bits version 3.98.2 (http://www.mp3dev.org/)
usage: blah blah
blah blah
C:\LAME>
if i try redirecting the output to a text file using > to a text file the text file is empty. Where is this text accessable from when running it using System.Process in c#?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
它可能会输出到 stderr 而不是 stdout。您可以通过执行以下操作重定向 stderr:
如果这显示了您的信息,则 LAME 是输出到标准错误流。如果您用 C# 编写包装器,则可以重定向 标准错误 和来自 ProcessStartInfo。
It may be output to stderr instead of stdout. You can redirect stderr by doing:
If this shows you information, then LAME is outputting to the standard error stream. If you write a wrapper in C#, you can redirect the standard error and output streams from ProcessStartInfo.
工作了。谢谢大家!
worked. thanks all!
它可能正在使用 stderr。 cmd.exe 不允许您重定向 stderr,而我重定向它的唯一方法是使用 djgpp 工具。
It's probably using stderr. cmd.exe doesn't allow you to redirect stderr, and the only way I've ever redirected it is with a djgpp tool.
它可能会被发送到 stderr,你尝试过吗?
查看 Process.StandardError< /a>.
尝试使用
It might be sent to stderr, have you tried that?
Check out Process.StandardError.
Try it out using