Pipe PuTTY console to Python script

主宰稳场 提交于 2021-02-20 05:15:37

问题


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.

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!

Code for launching PuTTY window:

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

回答1:


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

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

See:

  • Using the command-line connection tool Plink.
  • Run Unix commands using PuTTY in C#



回答2:


PuTTY (note case) is a GUI program and has nothing what so ever to do with cmd prompts.

I use PuTTY all day and out of a lot of people (my coy has 175,000 employees but most wouldn't use PuTTY) I'm the only one that automates it. I use VBScript sendkeys bound to hotkeys in windows shortcuts (must be on desktop or start menu).

PuTTY does have a command line version with a similar name, but I've not used it.



来源:https://stackoverflow.com/questions/28311315/pipe-putty-console-to-python-script

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!