将PuTTY控制台管道传输到Python脚本 [英] Pipe PuTTY console to Python script

查看:125
本文介绍了将PuTTY控制台管道传输到Python脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图启动建立串行连接的PuTTY窗口,然后让主cmd窗口(启动我的Python脚本的cmd窗口)控制PuTTY窗口.PuTTY窗口仍将打开并显示所有内容,但是我想在其上禁用标准输入,只是让它从cmd shell获取输入.

I am trying to launch a PuTTY window that establishes a serial connection, and then have the main cmd window (the one that launched my Python script) control the PuTTY window. The PuTTY window will still be open and showing everything, but I want to disable the stdin on it and just have it get the input from the cmd shell.

所以我成功启动了PuTTY窗口,似乎无法像我想要的那样输出我的输出和输入.任何帮助将不胜感激!

So I have it successfully launching the PuTTY window, just cant seem to pipe my outputs and inputs like I want. Any help would be greatly appreciated!

启动PuTTY窗口的代码:

Code for launching PuTTY window:

pty=subprocess.Popen(cmd,stdin=subprocess.PIPE,stdout=subprocess.PIPE)

推荐答案

PuTTY是GUI应用程序.它不是为自动化而设计的.

PuTTY is a GUI application. It is not designed for automation.

要实现自动化,请使用Plink,PuTTY命令行实用程序.这是一个控制台应用程序,因此它从其标准输入中读取命令.

For automation, use the Plink, PuTTY command-line utility. It is a console application, so it reads commands from its standard-input.

请参阅:

这篇关于将PuTTY控制台管道传输到Python脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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