Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I use Expect on Windows without installing Cygwin?

Expect is a module used for spawning child applications and controlling them. I'm interested in Python and Ruby.

like image 480
Geo Avatar asked Jun 25 '09 09:06

Geo


People also ask

Is Cygwin safe to install?

Cygwin is safe for all practical purposes. It's an executable, and it downloads a bunch of applications compiled for cygwin. Just make sure you have about 200MB for the install...

Does Cygwin require admin rights?

Sometimes you work on Windows as a restricted user, without admin rights. Like many other good software packages, Cygwin can be installed anyway (see the respective FAQ entry).

Which version of Cygwin?

The most recent version of the Cygwin DLL is 3.3.6. The Cygwin DLL currently works with all recent, commercially released x86_64 versions of Windows, starting with Windows Vista.


1 Answers

There is WExpect for Python.

Notes in the wexpect.py file (typos unchanged and highlighting added)

Wexpect is a port of pexpext to Windows. Since python for Windows lacks the requisite modules (pty, tty, select, termios, fctnl, and resource) to run pexpect, it was necessary to create a back-end that implemented any functions that were used that relied on these modules. Wtty.py is this back-end. In the Windows world consoles are not homogeneous. They can use low level or high level input and output functions, and to correctly deal with both cases two child processes are created for instacne of Spawn, with an intermidate child that can continuously read from the console, and send that data over a pipe to an instance of wtty. Spawner.py is resposible from reading and piping data.

I've left as much code intact as I could and also tried to leave as many comments intact is possible (espicially for functions that have not been changed) so many of the comments will be misleading in their relationship to os specific functionality. Also, the functions sendcontrol and sendeof are unimplemnted at this time, as I could not find meaningful Windows versions of these functions.
additionally, consoles do not have associated fild descriptors on Windows, so the global variable child_fd will always be None.

like image 63
nik Avatar answered Oct 01 '22 19:10

nik