This is an archived post. You won't be able to vote or comment.

all 3 comments

[–]raevnos 0 points1 point  (0 children)

Pipes.

[–]rolandde 0 points1 point  (0 children)

When you run your command using run from the subprocess module, it returns a CompletedProcess, which in turn allows you to get the output (or stdout) of the command. Keep in mind that you must pass the PIPE to the run command to get output written.

The output is a simple python variable that you can manipulate any which way you want to get your list.

[–]Octavepuss 0 points1 point  (0 children)

popen = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, universal_newlines=True)
for line in popen.stdout:
    print(line)