I am taking a step back, and just get something simple working with ANSI.
 The following code works (creates the ANSI terminal object, and inserts a
few characters, and scrap the characters back).

import ANSI

crt = ANSI.ANSI(25,80)

crt.insert_abs(2,2,"a")
crt.insert_abs(3,10,"b")
crt.insert_abs(5,5,"z")

print crt.get_region(1, 1, 5, 10)

But if I try to print something to the screen, the ANSI terminal doesn't
capture anything.

import ANSI
import os

crt = ANSI.ANSI(25,80)

crt.insert_abs(2,2,"a")
crt.insert_abs(3,10,"b")
crt.insert_abs(5,5,"z")

head_output = os.system("head -n 10 long_text_file.txt")
print head_output

print crt.get_region(1, 1, 5, 10)

How can I get the head output into the ANSI terminal?  My example code is
similar to the the usage example from the link below.  Yet ANSI is not
scraping the screen.  What am I doing wrong?

http://coding.derkeiler.com/Archive/Python/comp.lang.python/2005-03/1441.html

Thanks for any help.

On Sat, Nov 1, 2008 at 5:03 PM, Henry Chang <[EMAIL PROTECTED]> wrote:

> 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