Dang Duy Nam
Dang Duy Nam

Reputation: 337

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

The content is on stdout

I'm trying to get the result of this package using Nodejs. I have been trying to use spawn, exec and log the child_process object to debug it but cannot see the value on stdout, even though the stderr data is ok.

when I direct terminal output, I'm able to log the stderr, but stdout is just empty if I log it to file, but it does show up in the terminal.

Then I tried using just the tool to check result then thought it's the tool problem, not the Nodejs code.

EDIT: Adding terminal content in text

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$

Upvotes: 0

Views: 274

Answers (1)

Elliot Nelson
Elliot Nelson

Reputation: 11557

It sounds to me like the issue isn't really nodejs related. I did some quick googling on this Lola tool, and it looks like it might have some custom stdout/stderr, so it is possible for it to behave differently when used regularly from the terminal than when you specify redirects for the stdout and stderr.

One possible fix for you would be to use the --json option and specify a temporary filename, then have your nodejs code read the result from the temporary file created. (If you can't figure out the stdout/stderr issue.)

Upvotes: 0

Related Questions