Python 3.7 - Reading text from Terminal window

Thomas Jollans tjol at tjol.eu
Fri Jul 26 05:09:10 EDT 2019


On 26/07/2019 06.33, nir.zairi at gmail.com wrote:
> 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')
>
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





More information about the Python-list mailing list