Executing command line programs from within python [duplicate] Executing command line programs from within python [duplicate] python python

Executing command line programs from within python [duplicate]


The subprocess module is the preferred way of running other programs from Python -- much more flexible and nicer to use than os.system.

import subprocess#subprocess.check_output(['ls', '-l'])  # All that is technically needed...print(subprocess.check_output(['ls', '-l']))


This whole setup seems a little unstable to me.

Talk to the ffmpegx folks about having a GUI front-end over a command-line backend. It doesn't seem to bother them.

Indeed, I submit that a GUI (or web) front-end over a command-line backend is actually more stable, since you have a very, very clean interface between GUI and command. The command can evolve at a different pace from the web, as long as the command-line options are compatible, you have no possibility of breakage.


If you're concerned about server performance then look at capping the number of running sox processes. If the cap has been hit you can always cache the request and inform the user when it's finished in whichever way suits your application.

Alternatively, have the n worker scripts on other machines that pull requests from the db and call sox, and then push the resulting output file to where it needs to be.