Stdout

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • gbastian@pasteur.fr

    #1

    Stdout

    Dear Users,

    I am trying to recover through the python function
    popen3 the stdout,in,err of a launched process.

    I would like also to recover the stdout which you can
    get only through the command: command1 >& filename

    Do you know how I can access to that stdout by python?

    Thanks

    GIacomo

  • Dustan

    #2
    Re: Stdout

    On Apr 14, 2:49 am, gbast...@pasteu r.fr wrote:
    Dear Users,
    >
    I am trying to recover through the python function
    popen3 the stdout,in,err of a launched process.
    >
    I would like also to recover the stdout which you can
    get only through the command: command1 >& filename
    >
    Do you know how I can access to that stdout by python?
    I'm not sure if I understand your entire post, but in python, you get
    access to stdout through the sys module:
    >>print 'hello, world!'
    hello, world!
    >>import sys
    >>sys.stdout.wr ite('hello, world!')
    hello, world!
    >>>
    Thanks
    >
    GIacomo

    Comment

    • hlubenow

      #3
      Re: Stdout

      gbastian@pasteu r.fr wrote:
      Dear Users,
      >
      I am trying to recover through the python function
      popen3 the stdout,in,err of a launched process.
      >
      I would like also to recover the stdout which you can
      get only through the command: command1 >& filename
      >
      Do you know how I can access to that stdout by python?
      >
      Thanks
      >
      GIacomo
      Check out module "subprocess " which is meant to replace function "popen3":

      pr = subprocess.Pope n(["command", "-option1", "-option2"], stdin =
      subprocess.PIPE , stdout = subprocess.PIPE , stderr = subprocess.PIPE ,
      bufsize = 0, close_fds = True)

      # And then:
      line = pr.stdout.readl ine()
      print line
      pr.stdin.write( "hello to command")

      HTH

      H.

      Comment

      Working...