views:

231

answers:

1

I'm building a Python script to automate my build process, which invokes GCC using subprocess.Popen. My initial attempt works fine.

>>> import subprocess
>>> p = Popen(['gcc', 'hello.c'], stdout=subprocess.PIPE, stderr=stderr=subprocess.STDOUT)
>>> p.wait()
0
>>> p.communicate()
('', None)

However, once I pass additional options to GCC I get the error "no input files", as demonstrated below:

>>> import subprocess
>>> p = Popen(['gcc', '-o hello hello.c'], stdout=subprocess.PIPE, stderr=stderr=subprocess.STDOUT)
>>> p.wait()
1
>>> p.communicate()
('gcc: no input files\r\n', None)

Any ideas what may be causing this issue?

+3  A: 

Shouldn't that be

p = Popen(['gcc', '-o', 'hello', 'hello.c'], stdout=subprocess.PIPE, stderr=stderr=subprocess.STDOUT)
eduffy
Thanks, that works just fine! :)
stackoverflow