You probably want something like Pexpect
. It's been a while and there may be a better alternative now, but it will allow you to do what you want.
As far as I know, there is no easy way to do this with os.popen or commands in a module subprocess
.
source
to share