【问题标题】:Why does redirecting StandardOutput of GAWK always prepend fstat为什么重定向 GAW​​K 的 StandardOutput 总是在 fstat 前面
【发布时间】:2017-02-14 21:14:02
【问题描述】:

我有以下代码来读取 gawk 的输出并将其转换为文本文件(而不是使用 shell-execute 和使用 >):

var processStartInfo = new ProcessStartInfo
                       {
                         FileName = "gawk.exe",
                         Arguments = $@"-F ""{separator}"" -f ""{scriptFullFileName}"" ""{inputFullFileName}""",
                         UseShellExecute = false,
                         WorkingDirectory = workingDirectory,
                         RedirectStandardOutput = true,
                         CreateNoWindow = true
                       };
using (var process = Process.Start(processStartInfo))
{
  using (var streamReader = process.StandardOutput)
  {
    var result = streamReader.ReadToEnd();
  }
}

之后检查result,它总是以以下几行开头:

fstat fstat

虽然从 shell 执行 gawk.exe,但这些行不存在。

我做错了什么 - 或者更好的是,如何在不进行额外解析的情况下摆脱这两行?

【问题讨论】:

    标签: process output io-redirection


    【解决方案1】:

    这个问题与使用的 gawk.exe 版本有关,即3.1.6.2962。 使用4.1.3 不会出现此问题。

    【讨论】:

      猜你喜欢
      • 2016-12-22
      • 1970-01-01
      • 1970-01-01
      • 2011-07-11
      • 1970-01-01
      • 2020-03-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多