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.

1
  • 2
    That's not results, it's an error. Thus, it's probably on stderr, not stdout. Commented Feb 18, 2020 at 20:54

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

2 Comments

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.
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.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.