可以看到终端输出但无法使用 shell 重定向器将其保存到文件

Can see the terminal output but cannot save it to file using shell redirector

The content is on stdout

我正在尝试使用 Nodejs 获取此包的结果。我一直在尝试使用 spawn、exec 和 log child_process 对象来调试它,但看不到 stdout 上的值,即使 stderr 数据正常。

当我直接终端输出时,我能够记录 stderr,但如果我将它记录到文件,stdout 只是空的,但它确实显示在终端中。

然后我尝试只使用工具检查结果,然后认为是工具问题,而不是 Nodejs 代码。

编辑:在文本中添加终端内容

Macbooks-MacBook-Pro:query macos$ lola --formula="EF DEADLOCK" input.lola --quiet --json
{"analysis": {"formula": {"parsed": "EF (DEADLOCK)", "parsed_size": 13, "type": "deadlock"}, "result": true, "stats": {"edges": 3, "states": 4}}, "call": {"architecture": 64, "assertions": false, "build_system": "x86_64-apple-darwin17.7.0", "error": null, "hostname": "Macbooks-MacBook-Pro.local", "optimizations": true, "package_version": "2.0", "parameters": ["--formula=EF DEADLOCK", "input.lola", "--quiet", "--json"], "signal": null, "svn_version": "Unversioned directory"}, "files": {"net": {"filename": "input.lola"}}, "limits": {"markings": null, "time": null}, "net": {"conflict_sets": 6, "filename": "input.lola", "places": 8, "places_significant": 6, "transitions": 7}, "store": {"bucketing": 16, "encoder": "bit-perfect", "threads": 1, "type": "prefix"}}
Macbooks-MacBook-Pro:query macos$ lola --formula="EF DEADLOCK" input.lola --quiet --json 2> aaa.txt
{"analysis": {"formula": {"parsed": "EF (DEADLOCK)", "parsed_size": 13, "type": "deadlock"}, "result": true, "stats": {"edges": 3, "states": 4}}, "call": {"architecture": 64, "assertions": false, "build_system": "x86_64-apple-darwin17.7.0", "error": null, "hostname": "Macbooks-MacBook-Pro.local", "optimizations": true, "package_version": "2.0", "parameters": ["--formula=EF DEADLOCK", "input.lola", "--quiet", "--json"], "signal": null, "svn_version": "Unversioned directory"}, "files": {"net": {"filename": "input.lola"}}, "limits": {"markings": null, "time": null}, "net": {"conflict_sets": 6, "filename": "input.lola", "places": 8, "places_significant": 6, "transitions": 7}, "store": {"bucketing": 16, "encoder": "bit-perfect", "threads": 1, "type": "prefix"}}
Macbooks-MacBook-Pro:query macos$

在我看来这个问题与 nodejs 无关。我在这个 Lola 工具上做了一些快速谷歌搜索,看起来它可能有一些自定义 stdout/stderr,因此当从终端定期使用时它的行为可能与您为 stdout 和 stderr 指定重定向时的行为不同.

一个可能的修复方法是使用 --json 选项并指定一个临时文件名,然后让您的 nodejs 代码从创建的临时文件中读取结果。 (如果您无法弄清楚 stdout/stderr 问题。)