Calling Shell Commands from Python: OS.system vs Subprocessby@marcosdelcueto
24,036 reads

Calling Shell Commands from Python: OS.system vs Subprocess

tldt arrow
EN
Read on Terminal Reader
Read this story w/o Javascript

Too Long; Didn't Read

Calling Shell Commands from Python is useful to be familiar with how to call these commands efficiently from your Python code. In this short article, I discuss how to use the older (although still relatively common) os.system command and the newer subprocess command. I will show some of their potential risks, limitations and provide complete examples of their use. For example, the code below would be equivalent to the previouse code below. The article also provides examples of the use of these commands.

People Mentioned

Mention Thumbnail

Company Mentioned

Mention Thumbnail
featured image - Calling Shell Commands from Python: OS.system vs Subprocess
Marcos del Cueto HackerNoon profile picture

@marcosdelcueto

Marcos del Cueto


Receive Stories from @marcosdelcueto

react to story with heart

RELATED STORIES

L O A D I N G
. . . comments & more!
Hackernoon hq - po box 2206, edwards, colorado 81632, usa