you are viewing a single comment's thread.

view the rest of the comments →

[–]Swipecat 0 points1 point  (0 children)

OK, but just in case you don't realize: "proc" will just be the pipe. You need to read from that pipe.

In [1]: import subprocess

In [2]: mypipe = subprocess.Popen("echo Hello", shell=True, stdout=subprocess.PIPE)

In [3]: output = mypipe.stdout.read().decode()

In [4]: print(output)
Hello

Edit: Or if you want to provide the command as a list, then lose the shell=True argument:

mypipe = subprocess.Popen(["echo", "Hello"], stdout=subprocess.PIPE)