Pexpect version 4.2 — Pexpect 4.2.1 documentation

# Pexpect version 4.2

Pexpect makes Python a better tool for controlling other applications.

Pexpect is a pure Python module for spawning child applications; controlling them; and responding to expected patterns in their output. Pexpect works like Don Libes’ Expect. Pexpect allows your script to spawn a child application and control it as if a human were typing commands.

Pexpect can be used for automating interactive applications such as ssh, ftp, passwd, telnet, etc. It can be used to a automate setup scripts for duplicating software package installations on different servers. It can be used for automated software testing. Pexpect is in the spirit of Don Libes’ Expect, but Pexpect is pure Python. Unlike other Expect-like modules for Python, Pexpect does not require TCL or Expect nor does it require C extensions to be compiled. It should work on any platform that supports the standard Python pty module. The Pexpect interface was designed to be easy to use.

Contents:

- Installation
  - Requirements
- API Overview
  - Special EOF and TIMEOUT patterns
  - Find the end of line – CR/LF conventions
  - Beware of + and * at the end of patterns
  - Debugging
  - Exceptions
  - Pexpect on Windows
- API documentation
  - Core pexpect components
  - fdpexpect - use pexpect with a file descriptor
  - popen_spawn - use pexpect with a piped subprocess
  - replwrap - Control read-eval-print-loops
  - pxssh - control an SSH session
- Examples
- FAQ
- Common problems
  - Threads
  - Timing issue with send() and sendline()
  - Truncated output just before child exits
  - Controlling SSH on Solaris
  - child does not receive full input, emits BEL
- History
  - Releases
  - Moves and forks

Pexpect is developed on Github. Please report issues there as well.

# Indices and tables

- Index
- Module Index
- Search Page