Wexpect version 4.0.1

Build status

Wexpect is a Windows variant of Pexpect Wexpect and Pexpect makes Python a better tool for controlling other applications.

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

Wexpect 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. Wexpect highly depends on Mark Hammond’s pywin32 which provides access to many of the Windows APIs from Python.

Install

Wexpect is on PyPI, and can be installed with standard tools:

pip install wexpect

Hello Wexpect

To interract with a child process use spawn method:

import wexpect
child = wexpect.spawn('cmd.exe')
child.expect('>')
child.sendline('ls')
child.expect('>')
print(child.before)
child.sendline('exit')

For more information see examples folder.

Contents:

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

Indices and tables