How to flush pexpect spawn class buffer for subsequent expect calls??

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Mohit Batra
    New Member
    • Jul 2011
    • 1

    How to flush pexpect spawn class buffer for subsequent expect calls??

    Python pexpect module's "spawn" class lets you interact with a spawned child process.

    As per its official API documentation on http://pexpect.sourceforge.net/pexpect.html


    *************** *************** *************** ****
    The maxread attribute sets the read buffer size. This is maximum number
    of bytes that Pexpect will try to read from a TTY at one time. Setting
    the maxread size to 1 will turn off buffering. Setting the maxread
    value higher may help performance in cases where large amounts of
    output are read back from the child. This feature is useful in
    conjunction with searchwindowsiz e.

    The searchwindowsiz e attribute sets the how far back in the incomming
    seach buffer Pexpect will search for pattern matches. Every time
    Pexpect reads some data from the child it will append the data to the
    incomming buffer. The default is to search from the beginning of the
    imcomming buffer each time new data is read from the child. But this is
    very inefficient if you are running a command that generates a large
    amount of data where you want to match The searchwindowsiz e does not
    effect the size of the incomming data buffer. You will still have
    access to the full buffer after expect() returns.
    *************** *************** *************** *******



    Now my problem lies in that fact that executing "expect()" function more than once just keep on appending to the spawn class buffer inspite of the fact that I have set "maxread" to 1 and "searchwindowsi ze" to 0 in the spawn class constructor.

    child = pexpect.spawn(l ogin_string, timeout=20,logf ile=None,maxrea d=1,searchwindo wsize=0)

    Due to this, my program logic is not working correctly.
    Can anyone please help me out quickly.....???

    SOS

    pls posts replies to ***********

    -Thanks in advance,
    Mohit
    Last edited by bvdet; Jul 15 '11, 04:26 PM. Reason: Removed email address
Working...