I've had a hard time using pexpect in order to fill prompts but I've managed to write something working:
def call_and_type(command, prompt_regex, entry):
p = pexpect.spawn(command, logfile=sys.stdout, maxread=16384)
index = p.expect_exact([prompt_regex, pexpect.EOF])
if index == 0:
p.setecho(False)
p.sendline(entry)
while p.read():
pass