Skip to content Skip to sidebar Skip to footer

Python Subprocess Supress Stdout And Stderr

I call an external binary using the subprocess module: try: subprocess.check_output([param1, param2], stderr=subprocess.STDOUT) except subprocess.CalledProcessError as e: p

Solution 1:

check_output is a convenience function with limited functionality. If it doesn't do what you want, roll your own:

proc = subprocess.Popen([param1, param2],
    stderr=subprocess.PIPE)
out, err = proc.communicate()
if proc.returncode != 0:
    print(err)

Post a Comment for "Python Subprocess Supress Stdout And Stderr"