subprocess escaping POpen?!

Discussion in 'Python' started by Chris Withers, Aug 5, 2010.

  1. Hi All,

    I have a script that does the following:

    from subprocess import Popen,PIPE,STDOUT

    def execute(command,cwd):
    return Popen(
    command,
    stderr=STDOUT,
    stdout=PIPE,
    universal_newlines=True,
    cwd=cwd,
    shell=True,
    ).communicate()[0]

    captured = execute('svn up .')

    Now, if the subversion update requires authentication credentials, it
    manages to write to the console running the above script, *and* read
    input from it too.

    This is a bit baffling to me, I thought Popen.communicate() was happily
    hoovering all the output to stdout and stderr into the result returned
    from communicate?

    And, indeed, if I change the script instead to do:

    import sys
    f = open('test.py','w')
    f.write('import sys; sys.stderr.write("Hello!\\n")')
    f.close()
    captured = execute('test.py')

    ....then the output is indeed captured. So, what is svn doing
    differently? How is it escaping its jail?

    Chris
     
    Chris Withers, Aug 5, 2010
    #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. Michele Simionato

    subprocess.Popen

    Michele Simionato, Dec 12, 2004, in forum: Python
    Replies:
    5
    Views:
    17,674
  2. Ivo Woltring
    Replies:
    4
    Views:
    3,561
    Jeff Shannon
    Jan 27, 2005
  3. Replies:
    4
    Views:
    560
    Flash Gordon
    Dec 11, 2005
  4. Chris Withers

    Re: subprocess escaping POpen?!

    Chris Withers, Aug 5, 2010, in forum: Python
    Replies:
    2
    Views:
    293
    Lawrence D'Oliveiro
    Aug 6, 2010
  5. File.popen/IO.popen

    , May 20, 2006, in forum: Ruby
    Replies:
    1
    Views:
    238
    Robert Klemme
    May 20, 2006
Loading...

Share This Page