cmd doesn't output results to a file

511 Views Asked by At

I'm trying to use the cmd line, eventually putting it into a .bat to run a program, taking the return value and putting it into a .txt file. In this script it runs the program, creates the .txt file, but the .txt file is blank, while the program puts out a bunch of text on one line:

This is the command:

jsonlint test.json -c -q > test1.txt

The test1.txt gets create, but is blank. The program returns this value:

test.json: line 3, col13, found: 'NUMBER' - expected: 'EOF', '}', ':', ',', ']'.**

Why would this return value not be getting saved to the test1.txt file? Any thoughts or ideas are most appreciated. Thank you.

1

There are 1 best solutions below

2
marc-92 On

As Charles has mentioned, your output is actually an error indicating that your JSON file test.json is syntactically incorrect on line 3 col 13.

If you want to have whatever is output regardless of it being STDOUT or STDERR, then at the end of your command you can add 2>&1 to redirect your STDERR to STDOUT, so it would look like this:

jsonlint test.json -c -q > test1.txt 2>&1

More on redirecting error messages here.