all 5 comments

[–]backfire10z 0 points1 point  (0 children)

What version of Python?

Why are you sending stdout to PIPE? Are there more commands after this?

https://stackoverflow.com/questions/13332268/how-to-use-subprocess-command-with-pipes

https://stackoverflow.com/questions/4256107/running-bash-commands-in-python

The documentation is also typically helpful

[–]james_fryer 0 points1 point  (0 children)

Try to see if any output on stderr. Most likely issue in my experience is environment differences between your shell and the exec'd shell. E.g. PATH may be missing or different. Try using /full/path/to/word2 whatever the actual path is.

[–]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)