O'Reilly logo

Mastering Python for Networking and Security by Jose Manuel Ortega

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Subprocess module

The standard subprocess module allows you to invoke processes from Python and communicate with them, send data to the input (stdin), and receive the output information (stdout). Using this module is the recommended way to execute operating system commands or launch programs (instead of the traditional os.system ()) and optionally interact with them.

Running a child process with your subprocess is simple. Here, the Popen constructor starts the process. You can also pipe data from your Python program into a subprocess and retrieve its output. With the help(subprocess) command, we can see that information:

The simplest way to ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required