[Tutor] Popen problem with a pipe sign "|"

hyou hyou00 at hotmail.com
Mon Jul 6 15:50:01 CEST 2009


Hi Sander,

Do I post to the list by also replying to Python Tutor List?

Thanks for the answer! I found the problem was because I put the 2nd
argument to Popen with Shell = true. Though I'm not sure why it doesn't work
with Shell = true while the same setting works for other commands.

Thanks again and have a great week!

Cheers,
Shawn

P.S. If you know the reason why some command works for Shell = true some
not, please let me know!

-----Original Message-----
From: Sander Sweers [mailto:sander.sweers at gmail.com] 
Sent: Saturday, July 04, 2009 12:57 PM
To: Shawn Gong
Cc: Python Tutor List
Subject: Re: [Tutor] Popen problem with a pipe sign "|"

Again, You need to also post to the list!!

On Fri, 2009-07-03 at 22:32 -0400, Shawn Gong wrote:
> I see what you mean. However in my case the | sign simply constitute an 
> argument. I'm actually calling devenv.com, which is the MS VS2005's
building 
> command. The whole command looks like:
> "...\devenv.com" solution.sln /build "Debug|Win32"
> If I sub "Debug|Win32" with Debug only, it works fine. But whenever I add 
> the |, nothing seems to run.

Ah, ok now I get what your problem is.

I do not know why that would not work. Can you show the actual code you
have? Do you have the command in a list? See below an *untested*
example, does this work?

command = ['C:\\...\\devenv', 'solution.sln', '/build', 'Debug|Win32']
proc = subprocess.Popen(command,
                        stdout=subporcess.PIPE,
                        stderr=subporcess.PIPE,
                        stdin=subporcess.PIPE)

stdout, stderr = proc.communicate()




More information about the Tutor mailing list