Possible Duplicate:
How do I execute a program from python? os.system fails due to spaces in path
I am trying to call a program (MP3gain.exe) in command line from python. my problem is that python puts a [' '] around the command that I am sending to command line, and dos doesn't appear to be able to interpret the command with that. Here is my code.
import os
import subprocess
import Editor
class normalize():
def __init__(self, file):
self.FileName = file
def work(self):
command = [ 'mp3gain /r /c' + self.FileName]
subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
if __name__ == "__main__":
test = normalize("filename.mp3")
test.work()
In case this helps, if I have dos print out the exit code, it is -2. Thanks for any help.
python puts a [' '] around the command? You're not supposed to have an actual snake type the code for you, it's just the language name.mp3gain /r /c filename.mp3- have you triedcommand = ['mp3gain', '/r', '/c', self.FileName]? (also mp3gain will have to be callable from the interpreter's working directory - otherwise, you may need to call the path for the full executable)