Python subprocess.Popen - adding GCC flags results in “no input files” error
-
11-09-2019 - |
Question
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?
Solution
Shouldn't that be
p = Popen(['gcc', '-o', 'hello', 'hello.c'], stdout=subprocess.PIPE, stderr=stderr=subprocess.STDOUT)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow