Pexpect Documentation
Pexpect Documentation
Release 4.8 Noah Spurrier and contributors
Sep 12, 2023
Contents
1 Installation
3
1.1 Requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
2 API Overview
5
2.1 Special EOF and TIMEOUT patterns . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
2.2 Find the end of line ? CR/LF conventions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
2.3 Beware of + and * at the end of patterns . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
2.4 Debugging . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
2.5 Exceptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
2.6 Pexpect on Windows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
3 API documentation
11
3.1 Core pexpect components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
3.2 fdpexpect - use pexpect with a file descriptor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
3.3 socket_pexpect - use pexpect with a socket . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
3.4 popen_spawn - use pexpect with a piped subprocess . . . . . . . . . . . . . . . . . . . . . . . . . . 25
3.5 replwrap - Control read-eval-print-loops . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
3.6 pxssh - control an SSH session . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
4 Examples
33
5 FAQ
35
6 Common problems
39
6.1 Threads . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
6.2 Timing issue with send() and sendline() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
6.3 Truncated output just before child exits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
6.4 Controlling SSH on Solaris . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
6.5 child does not receive full input, emits BEL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
7 History
41
7.1 Releases . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
7.2 Moves and forks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
8 Indices and tables
49
Python Module Index
51
i
Index
53
ii
Pexpect Documentation, Release 4.8
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 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:
Contents
1
Pexpect Documentation, Release 4.8
2
Contents
1 CHAPTER
Installation
Pexpect is on PyPI, and can be installed with standard tools: pip install pexpect Or: easy_install pexpect
1.1 Requirements
This version of Pexpect requires Python 3.3 or above, or Python 2.7. As of version 4.0, Pexpect can be used on Windows and POSIX systems. However, pexpect.spawn and pexpect.run() are only available on POSIX, where the pty module is present in the standard library. See Pexpect on Windows for more information.
3
Pexpect Documentation, Release 4.8
4
Chapter 1. Installation
................
................
In order to avoid copyright disputes, this page is only a partial summary.
To fulfill the demand for quickly locating and searching documents.
It is intelligent file search solution for home and business.
Related searches
- history and physical documentation guide
- medical student documentation and cms
- documentation guidelines for medical students
- history and physical documentation guid
- completed assessment documentation examples
- cms medical student documentation 2018
- medical student documentation guidelines 2019
- student documentation in medical records
- cms student documentation requirements
- free printable homeschool documentation forms
- employee conversation documentation template
- cms surgery documentation guidelines