child = pexpect.spawn('some command that requires password')
child.expect('Enter password:')
child.sendline('password')
child.expect(pexpect.EOF, timeout=None)
Simplest way to run expect script from python