passing ctrl+z to pexpect

pexpect, python

Solution

use sendcontrol()

for example:

p = pexpect.spawn(your_cmd_here)
p.sendcontrol('z')

Problem

How do I pass a certain key combination to a spawned/child process using the pexpect module? I'm using telnet and have to pass Ctrl+Z to a remote server. Tnx

Original source