Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Python 3.7 - Reading text from Terminal window

99 views
Skip to first unread message

nir....@gmail.com

unread,
Jul 26, 2019, 12:33:46 AM7/26/19
to
Hi,

I want it to wait for a specific text on the terminal window that it opens (putty.exe), how can i do it?

from pywinauto.application import Application
from pynput.keyboard import Key, Controller

print('Configuring')

app = Application().start(cmd_line=u'"C:\\...putty.exe" ')
puttyconfigbox = app.PuTTYConfigBox
puttyconfigbox.wait('ready')
listbox = puttyconfigbox.ListBox
listbox.select(u'COM5')
button = puttyconfigbox[u'&Load']
button.click()
button2 = puttyconfigbox[u'&Open']
button2.click()

keyboard = Controller()
keyboard.press(Key.enter)

keyboard.type('password1')
keyboard.press(Key.enter)
keyboard.type('enable\nconf t\n')

Thomas Jollans

unread,
Jul 26, 2019, 5:36:25 AM7/26/19
to
Not a clue, but why are you using PuTTY at all? Can't whatever it is
you're doing be achieved much more simply using e.g. pyserial, accessing
the COM port directly from Python?

-- T


0 new messages