Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
3 views
in Python by (47.6k points)

I'm building a web application that will is going to manipulate (pad, mix, merge etc) sound files and I've found that sox do exactly what I want. Sox is a Linux command-line program and I'm feeling a little uncomfortable with having the python web app starting new sox processes on my server on a per request basis.

Example:

import os

os.system('sox input.wav -b 24 output.aiff rate -v -L -b 90 48k')

This whole setup seems a little unstable to me.

So my question is, what's the best practice for running command-line programs from within a python (or any scripting language) web app?

Message queues would be one thing to implement in order to get around the whole request-response cycle. But is there other ways to make these things more elegant?

1 Answer

0 votes
by (106k points)

For executing command-line programs from within python the subprocess module is the preferred way of running other programs from Python -- much more flexible and nicer to use than os.system. You can use the below-mentioned code:-

import subprocess 

subprocess.check_output(['ls','-l'])

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...