我可以在不安装Cygwin的情况下在Windows上使用Expect吗?

时间:2022-11-19 01:51:47

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

Expect是一个用于生成子应用程序并控制它们的模块。我对Python和Ruby感兴趣。

6 个解决方案

#1


17  

There is WExpect for Python.

有WExpect for Python。

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

wexpect.py文件中的注释(拼写错误并突出显示已添加)

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.

Wexpect是Windows的pexpext端口。由于用于Windows的python缺少必要的模块(pty,tty,select,termios,fctnl和resource)来运行pexpect,因此有必要创建一个后端来实现依赖于这些模块的任何使用的函数。 Wtty.py是这个后端。在Windows世界中,游戏机不是同质的。他们可以使用低级或高级输入和输出函数,并正确处理两种情况,为Spawn的instacne创建两个子进程,一个可以从控制台连续读取的中间子进程,并通过管道将该数据发送到一个wtty的例子。 Spawner.py可以读取和管道数据。

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.

我尽可能多地保留了完整的代码并且还试图保留尽可能多的注释(特别是对于尚未更改的函数),因此许多注释会在与os特定功能的关系中产生误导。此外,函数sendcontrol和sendeof目前还没有实现,因为我找不到这些函数的有意义的Windows版本。此外,控制台在Windows上没有关联的fild描述符,因此全局变量child_fd将始终为None。

#2


6  

winpexpect is a native port of pexpect to Windows. It can be found here:

winpexpect是Windows的本地端口。在这里能找到它:

https://github.com/geertj/winpexpect

https://github.com/geertj/winpexpect

#3


5  

You can use the Windows CMD prompt.

您可以使用Windows CMD提示符。

You need to have Python installed in your Windows installation.

您需要在Windows安装中安装Python。

Open a cmd prompt and execute the below command:

打开cmd提示符并执行以下命令:

C:\Users\xxx>pip install pexpect (if you have set the Python path in a system variable)

C:\ Users \ xxx> pip install pexpect(如果你在系统变量中设置了Python路径)

or

要么

C:\Users\xxx>c:\python27\scripts\pip.exe install pexpect

Collecting pexpect
  Downloading pexpect-4.0.1.tar.gz (143kB)
    100% |################################| 147kB 1.2MB/s
Collecting ptyprocess>=0.5 (from pexpect)
  Downloading ptyprocess-0.5.1-py2.py3-none-any.whl
Building wheels for collected packages: pexpect
  Running setup.py bdist_wheel for pexpect
  Stored in directory: C:\Users\xxx\AppData\Local\pip\Cache\wheels\f2\65\89\09578bcd0efeabc7e2b0079cd62d3955c1477f2e55aa5031a4
Successfully built pexpect
Installing collected packages: ptyprocess, pexpect
Successfully installed pexpect-4.0.1 ptyprocess-0.5.1

#4


2  

The latest working version of wexpect lives at http://sage.math.washington.edu/home/goreckc/sage/wexpect/

wexpect的最新工作版本位于http://sage.math.washington.edu/home/goreckc/sage/wexpect/

Hopefully it will be merged upstream soon.

希望它很快会合并到上游。

#5


2  

Use pexpect https://github.com/pexpect/pexpect

使用pexpect https://github.com/pexpect/pexpect

"Pexpect is pure Python" so it will run anywhere, without Cygwin too,

“Pexpect是纯Python”,所以它可以在任何地方运行,没有Cygwin,

edit: pexpect depends on pty module which is currently available only for Linux, so as Nik suggested you should be using wexpect which is a port of pexpect

编辑:pexpect依赖于目前仅适用于Linux的pty模块,因此Nik建议你应该使用wexpect,这是一个pexpect的端口

#6


0  

I've successfully used Pexpect under Cygwin. For now there is no other way due to POSIX compatibility problems under Windows.

我在Cygwin下成功使用了Pexpect。目前,由于Windows下的POSIX兼容性问题,没有其他办法。

Another thing: WExpect works like Pexpect, in fact it requires Cygwin! At this point, PExpect is a better choice.

另一件事:WExpect像Pexpect一样工作,实际上它需要Cygwin!在这一点上,PExpect是一个更好的选择。

#1


17  

There is WExpect for Python.

有WExpect for Python。

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

wexpect.py文件中的注释(拼写错误并突出显示已添加)

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.

Wexpect是Windows的pexpext端口。由于用于Windows的python缺少必要的模块(pty,tty,select,termios,fctnl和resource)来运行pexpect,因此有必要创建一个后端来实现依赖于这些模块的任何使用的函数。 Wtty.py是这个后端。在Windows世界中,游戏机不是同质的。他们可以使用低级或高级输入和输出函数,并正确处理两种情况,为Spawn的instacne创建两个子进程,一个可以从控制台连续读取的中间子进程,并通过管道将该数据发送到一个wtty的例子。 Spawner.py可以读取和管道数据。

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.

我尽可能多地保留了完整的代码并且还试图保留尽可能多的注释(特别是对于尚未更改的函数),因此许多注释会在与os特定功能的关系中产生误导。此外,函数sendcontrol和sendeof目前还没有实现,因为我找不到这些函数的有意义的Windows版本。此外,控制台在Windows上没有关联的fild描述符,因此全局变量child_fd将始终为None。

#2


6  

winpexpect is a native port of pexpect to Windows. It can be found here:

winpexpect是Windows的本地端口。在这里能找到它:

https://github.com/geertj/winpexpect

https://github.com/geertj/winpexpect

#3


5  

You can use the Windows CMD prompt.

您可以使用Windows CMD提示符。

You need to have Python installed in your Windows installation.

您需要在Windows安装中安装Python。

Open a cmd prompt and execute the below command:

打开cmd提示符并执行以下命令:

C:\Users\xxx>pip install pexpect (if you have set the Python path in a system variable)

C:\ Users \ xxx> pip install pexpect(如果你在系统变量中设置了Python路径)

or

要么

C:\Users\xxx>c:\python27\scripts\pip.exe install pexpect

Collecting pexpect
  Downloading pexpect-4.0.1.tar.gz (143kB)
    100% |################################| 147kB 1.2MB/s
Collecting ptyprocess>=0.5 (from pexpect)
  Downloading ptyprocess-0.5.1-py2.py3-none-any.whl
Building wheels for collected packages: pexpect
  Running setup.py bdist_wheel for pexpect
  Stored in directory: C:\Users\xxx\AppData\Local\pip\Cache\wheels\f2\65\89\09578bcd0efeabc7e2b0079cd62d3955c1477f2e55aa5031a4
Successfully built pexpect
Installing collected packages: ptyprocess, pexpect
Successfully installed pexpect-4.0.1 ptyprocess-0.5.1

#4


2  

The latest working version of wexpect lives at http://sage.math.washington.edu/home/goreckc/sage/wexpect/

wexpect的最新工作版本位于http://sage.math.washington.edu/home/goreckc/sage/wexpect/

Hopefully it will be merged upstream soon.

希望它很快会合并到上游。

#5


2  

Use pexpect https://github.com/pexpect/pexpect

使用pexpect https://github.com/pexpect/pexpect

"Pexpect is pure Python" so it will run anywhere, without Cygwin too,

“Pexpect是纯Python”,所以它可以在任何地方运行,没有Cygwin,

edit: pexpect depends on pty module which is currently available only for Linux, so as Nik suggested you should be using wexpect which is a port of pexpect

编辑:pexpect依赖于目前仅适用于Linux的pty模块,因此Nik建议你应该使用wexpect,这是一个pexpect的端口

#6


0  

I've successfully used Pexpect under Cygwin. For now there is no other way due to POSIX compatibility problems under Windows.

我在Cygwin下成功使用了Pexpect。目前,由于Windows下的POSIX兼容性问题,没有其他办法。

Another thing: WExpect works like Pexpect, in fact it requires Cygwin! At this point, PExpect is a better choice.

另一件事:WExpect像Pexpect一样工作,实际上它需要Cygwin!在这一点上,PExpect是一个更好的选择。