python控制应用程序_使用python控制终端应用程序

我有一个通过控制台运行的服务器程序. (具体来说,Bukkit MineCraft服务器)我希望能够控制这个程序并读取输出.没有GUI,所以它不应该太难,对吧?

无论如何,我从来没有在python中控制一个控制台而且完全卡住了.有什么建议?

附:我正在使用Debian Linux,因此应该简化一些事情.

我得到了一个很好的答案,但我还需要一件事.我想有一些方法将程序的FULL输出打印到python控制台(逐行排序很好),我需要一些方法将控制台中的命令转发到程序.

解决方法:

像这样的任务的规范答案是使用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. Pexpect is in the spirit of Don

Libes’ Expect, but Pexpect is pure Python. Other Expect-like modules for Python

require TCL and Expect or require C extensions to be compiled. Pexpect does not

use C, Expect, or TCL extensions. 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.

标签:python,terminal

来源: https://codeday.me/bug/20190621/1255156.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值