Using the below script, I can use pexpect to correctly output the entire
remote terminal content to screen.
At this point, I am running into difficulty to scrap the screen, for the
screen elements that I want.  (Say: the screen region from the complete 3rd
line to the 8th line.)  I believe I need to use ANSI module.  I tried a few
things, but have run out of ideas.

Can anyone please help?  How can the code below be modified to use ANSI?

Thanks so much for any help.


import pexpect

child = pexpect.spawn ('ssh [EMAIL PROTECTED]')
child.expect ('Password: ')

child.sendline ('dummy_password')
child.expect ('[513] ')

child.sendline ('w2ktt')  # windows 2000 terminal type
child.expect ('Command:')

child.sendline ('dummy_command')
child.expect('non-guest room')

# This will output the console to the screen.
print child.before

child.expect('Command:')
child.sendline ('logoff')
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to