How to get exit code when using Python subprocess communicate method?

How do I retrieve the exit code when using Python’s subprocess module and the communicate() method?

Relevant code:

import subprocess as sp
data = sp.Popen(openRTSP + opts.split(), stdout=sp.PIPE).communicate()[0]

Should I be doing this another way?

8 Answers
8

Leave a Comment