Reputation: 544
What I want to do is something very similar to the accepted answer in this question, however with a slight change. The last line:
print p3.communicate()[0]
prints the output of p3
. I would like to basically get subprocess.call()
-like behaviour there instead of simply receiving the output at stdout.
For example, if p3
was less, using communicate
, a pipe to less would behave more like a pipe to cat in that it wouldn't actually open less, but just print out the output.
Is there anyway to achieve what I'm after (which is actually opening less rather than just it behaving like cat and communicating its output)? A nod in the right direction would be fantastic.
Upvotes: 0
Views: 182
Reputation: 544
So instead of doing:
p3 = Popen(cmd, stdin=p2.stdout, stdout=PIPE)
...
print p3.communicate()[0]
I can just do:
subprocess.call(cmd, stdin=p2.stdout)
And that will allow me to do what I wanted. :)
Upvotes: 2