1 2 3 4 5 6 7 8
import pexpect p = pexpect.spawn(["login"]) p.expect("login:") p.sendline("wrong") p.expect("Password:") p.sendline("wrong") p.expect("Login incorrect")