0

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.

Gerhard
  • 22,678
  • 7
  • 27
  • 43

1 Answers1

0

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.

Gerhard
  • 22,678
  • 7
  • 27
  • 43
marc-92
  • 47
  • 3
  • 3
    I have down-voted this as it is simply a regurgitation if somebody else's comments. In addition to that, the comments clearly showed that this question has already been answered on this site, so is a duplicate, which didn't need answering again. – Compo Feb 19 '20 at 00:06
  • Thank you! I didn't know it wouldn't just put out everything on the line. Good information. Sorry it's a duplicate, but I searched this site and didn't find anything to help, so obviously it's not coming up with the query I put in. Perhaps my verbiage may be of help to someone else in the future. Thanks again. – Tim Williams Feb 19 '20 at 16:58