在 Python 脚本中包装交互式命令行应用程序 [英] Wrapping an interactive command line application in a Python script

查看:23
本文介绍了在 Python 脚本中包装交互式命令行应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对通过 Python 调用控制交互式 CLI 应用程序感兴趣.

I am interested in controlling an interactive CLI application from Python calls.

我想在最基本的层面上,我需要一个 Python 脚本来在主机操作系统上启动 CLI 应用程序.将标准输入中的任何内容通过管道传输到 CLI 应用程序,然后将 CLI 应用程序中的任何输出通过管道传输到标准输出.

I guess at the most basic level I need a Python script that will start a CLI application on the host operating system. Pipe anything from standard input to the CLI application, and then pipe any output from the CLI application to standard output.

在此基础上,对输入和输出进行一些处理应该非常简单.

From this base, it should be pretty straightforward to do some processing on the input and output.

老实说,我可能只需要一个关于该技术被称为什么的指针.我不知道我需要搜索什么.

To be honest, I probably just need a pointer on what the technique is called. I have no idea what I need to be searching for.

推荐答案

PExpect 是否符合您的需求?

这篇关于在 Python 脚本中包装交互式命令行应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆