Python Command Line input?

Question:

My Python script will run a bunch of shell scripts that output either 200 SOLUTIONS_REVISION or 400 SOLUTIONS_REVISION when run. The 200 in the output indicates success and the 400 indicates failure.

How can I capture these "returned" strings as strs in the Python code, for further processing?

Asked By: user475353

||

Answers:

If you’re going to run the command from your Python script then you want to look at subprocess with its stdout arguments. If you’re going to run both that script and the Python script from a separate shell script then you want to pipe from one to the next and then read from sys.stdin.

Categories: questions Tags:
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.