k0b0's record.

Computer Engineering, Arts and Books

Introduction to Python. Use shell command in python

Use shell command(unix or linux) in python

 To execute shell code in python, use subprocess.check_call (). An example of description is shown below.

Sample code (Example of executing 'ls' command)

# testOfShellcommand.py
import subprocess

args = ['ls','-l'] # The command to execute.

    res = subprocess.check_call(args) # Execute shell command.
    print ("Error.")