Filter out command that needs a terminal in Python subprocess module
问题 I am developing a robot that accepts commands from network (XMPP) and uses subprocess module in Python to execute them and sends back the output of commands. Essentially it is an SSH-like XMPP-based non-interactive shell. The robot only executes commands from authenticated trusted sources, so arbitrary shell commands are allowed ( shell=True ). However, when I accidentally send some command that needs a tty, the robot is stuck. For example: subprocess.check_output(['vim'], shell=False)