0

I have CLI program that with parameters works automatically, however it still has a TUI (for example something written with curses) which can't be disabled. I am trying :

subprocess.check_call([executable, '-parameter'], stdout=subprocess.DEVNULL)

It disables most of the output, but still there's some left (parts that change). How to completly disable output from it? Thank you.

Makalone LOgman
  • 948
  • 1
  • 12
  • 25
  • subprocess also takes input and output pipes, you will want to give it an output pipe – Nullman Mar 17 '19 at 14:32
  • 1
    Possible duplicate of [How to hide output of subprocess in Python 2.7](https://stackoverflow.com/questions/11269575/how-to-hide-output-of-subprocess-in-python-2-7) – Nullman Mar 17 '19 at 14:33
  • isn't the output pipe already set as `subprocess.DEVNULL`? – Makalone LOgman Mar 17 '19 at 14:35
  • [nope](https://stackoverflow.com/a/19961290/7540911) [`With the default settings of None, no redirection will occur; the child’s file handles will be inherited from the parent.`](https://docs.python.org/3.6/library/subprocess.html#frequently-used-arguments) – Nullman Mar 17 '19 at 14:36
  • okay. Thank you for explaination. BTW `stdout=FNULL, stderr=subprocess.STDOUT` worked. – Makalone LOgman Mar 17 '19 at 14:41

1 Answers1

0

You likely need to redirect both stdout AND stderr.

subprocess.check_call([executable, '-parameter'], 
    stdout=subprocess.DEVNULL,
    stderr=subprocess.DEVNULL
)
Matthew Wilcoxson
  • 3,432
  • 1
  • 43
  • 48