How to set explicitly the terminal size when using pexpect

JS_is_bad picture JS_is_bad · Oct 4, 2009 · Viewed 8.1k times · Source

I have a ncurses app that checks terminal size at startup and exits immediately if it doesn't fit.

In Linux, the default size is 80x24, this app requires at least 25. The fix is easy, I'm just resizing the terminal emulation window (in X) before running the ncurses app.

I would like to automate the ncurses app with pexpect, but I'm getting stuck because it considers the terminal size smaller than required when launched through pexpect, so it doesn't run. Any way to specify the terminal size with pexpect explicitly at startup?

Answer

rags picture rags · Jun 8, 2012

You can also use :

import pexpect
child = pexpect.spawn(cmd)
child.setwinsize(400,400)