Top Banner
Python Execute Unix / Linux Command l There are two modules in python to excute the linux commands. l 1. os module l 2. subprocess module
11

Python session 4 subprocess- by Gopal.A (Python developer)

Jun 24, 2015

Download

Education

Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Python session 4 subprocess- by Gopal.A (Python developer)

Python Execute Unix / Linux Command

l There are two modules in python to excute the linux commands.

l 1. os module l 2. subprocess module

Page 2: Python session 4 subprocess- by Gopal.A (Python developer)

l syntax:

l subprocess.call(args, *, stdin=None, stdout=None, stderr=None, shell=false)

Page 3: Python session 4 subprocess- by Gopal.A (Python developer)

l PASSING ARGUMENTS

Page 4: Python session 4 subprocess- by Gopal.A (Python developer)
Page 5: Python session 4 subprocess- by Gopal.A (Python developer)

l SUBPROCESS.POPEN( ) - STDOUT AND STDERR

Page 6: Python session 4 subprocess- by Gopal.A (Python developer)

l Popen.communicate() interacts with process: Send data to stdin. Read data from stdout and stderr, until end-of-file is reached.

Page 7: Python session 4 subprocess- by Gopal.A (Python developer)
Page 8: Python session 4 subprocess- by Gopal.A (Python developer)
Page 9: Python session 4 subprocess- by Gopal.A (Python developer)
Page 10: Python session 4 subprocess- by Gopal.A (Python developer)

SHELL VALUE

Page 11: Python session 4 subprocess- by Gopal.A (Python developer)