replace commands with pexpect