I want to run a script multiple times, with different paths as arguments, and see the output.
If I run the script path/lizard
with argument path_to_code/code1.cpp
in a command prompt
path/lizard path_to_code/code1.cpp
I get output - and I would like to run this script on multiple files.
Looking at this and similar questions, I tried
import os, glob
def run_command(command):
os.system(command)
program = '"C:/Python27/Scripts/lizard.bat "'
path = '"path_to_code/*.cpp"'
for path1 in glob.glob(path):
command = program + path1
run_command(command)
No output.
import glob, subprocess
def run_command(command):
p = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
out, err = p.communicate()
print out
program = '"C:/Python27/Scripts/lizard.bat "'
path = '"path_to_code/*.cpp"'
for path1 in glob.glob(path):
command = program + path1
run_command(command)
No output.
(of course i want to iterate recursively through directory but that is next step).
How can I get the output of the program running from script ? I think logically both versions should get me the output... What am I doing wrong ?