使用subprocess.Popen()包装脚本

时间:2021-06-04 00:27:05

I have a script that's provided with another software package - which I would not like to modify in any way. I need to execute this script, provide a password, and then interact with it from the terminal (using raw_input, etc.).

我有一个脚本,提供了另一个软件包 - 我不想以任何方式修改。我需要执行此脚本,提供密码,然后从终端与其进行交互(使用raw_input等)。

1 个解决方案

#1


pexpect is what you want to use.

pexpect是你想要使用的。

Pexpect is a Python module for spawning child applications and controlling them automatically. Pexpect 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. It should work on any platform that supports the standard Python pty module. The Pexpect interface focuses on ease of use so that simple tasks are easy.

Pexpect是一个Python模块,用于生成子应用程序并自动控制它们。 Pexpect可用于自动化交互式应用程序,如ssh,ftp,passwd,telnet等。它可用于自动化设置脚本,以便在不同服务器上复制软件包安装。它可用于自动化软件测试。它应该适用于任何支持标准Python pty模块的平台。 Pexpect界面侧重于易用性,因此简单的任务很容易。

#1


pexpect is what you want to use.

pexpect是你想要使用的。

Pexpect is a Python module for spawning child applications and controlling them automatically. Pexpect 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. It should work on any platform that supports the standard Python pty module. The Pexpect interface focuses on ease of use so that simple tasks are easy.

Pexpect是一个Python模块,用于生成子应用程序并自动控制它们。 Pexpect可用于自动化交互式应用程序,如ssh,ftp,passwd,telnet等。它可用于自动化设置脚本,以便在不同服务器上复制软件包安装。它可用于自动化软件测试。它应该适用于任何支持标准Python pty模块的平台。 Pexpect界面侧重于易用性,因此简单的任务很容易。