Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

4
  • 9
    Why is not recommendable to use import os? Commented Apr 25, 2016 at 1:27
  • @LuisRamonRamirezRodriguez, os.system() provides less control than the subprocess.Popen interface -- most importantly, it provides no way to pass data out-of-band from code (or to provide a literal argv array), making it hard to avoid shell injection vulnerabilities. Commented Jan 26, 2017 at 16:44
  • 1
    @dom0, shell=True is the wrong thing for your subprocess.call(["echo", i], shell=True) example: The shell script that's run is just echo, with no arguments, and the i is passed as an argument to the shell that the script doesn't refer to. Commented Jan 26, 2017 at 16:45
  • I edited the answer so as to propose the secure way first. Commented May 18, 2017 at 20:57