Problems redirecting STDOUT (NOT sys.stdout) to a pipe.

Discussion in 'Python' started by Elad, Mar 19, 2006.

  1. Elad

    Elad Guest

    Hello All,

    I am trying to capture some printf's from a C function called by
    python.
    <Working under winxp>

    I have tried to following:

    STDOUT = 1 # stdout fd
    (re, we) = os.pipe() # Create re / write handlers
    dup2(we, STDOUT) # override system's stdout, should dup first and
    restore later..

    call_my_hello_world() # if stdout is not overriden will print hello
    world on console screen

    x = os.read(re, 11)

    sadly, x = '' after the code is executed.

    help ? :)

    Thanks,

    Elad.
     
    Elad, Mar 19, 2006
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Roman Neuhauser
    Replies:
    0
    Views:
    661
    Roman Neuhauser
    Apr 4, 2005
  2. Ahmad Hosseinzadeh

    redirecting messgaef from sys.stdout

    Ahmad Hosseinzadeh, Jun 7, 2005, in forum: Python
    Replies:
    0
    Views:
    291
    Ahmad Hosseinzadeh
    Jun 7, 2005
  3. Replies:
    2
    Views:
    654
    velle
    Jan 5, 2006
  4. Replies:
    0
    Views:
    478
  5. Mitchell L Model

    sys.stdout vs. sys.stderr

    Mitchell L Model, Jan 11, 2010, in forum: Python
    Replies:
    2
    Views:
    569
    Nobody
    Jan 11, 2010
Loading...

Share This Page