title: How to wrap a CLI program in Python (keeping the interactivity)?
body: <p>I'd like to write a wrapper for an interactive CLI Program (the Asterisk CLI).</p>
  
  <p>Basically, I need to keep the interaction with the CLI (including tab-completion) but I want to filter the output of Asterisk, in order to show only lines matching a given pattern.</p>
  
  <p>I tried a select() based approach, using popen.popen4 and putting asterisk stdout_and_stderr and sys.stdin in the read_fs, but it sort of didn't work.</p>
  
  <p>Can anyone give some good pointers to me?</p>
  
  <p>Thanks a lot,
  Andrea</p>