Calling Shell Commands from Python: OS.system vs Subprocessby@marcosdelcueto
20,038 reads

Calling Shell Commands from Python: OS.system vs Subprocess

tldt arrow
EN
Read on Terminal Reader🖨️

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

Learn More
LEARN MORE ABOUT @MARCOSDELCUETO'S EXPERTISE AND PLACE ON THE INTERNET.
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