python session 4 subprocess- by gopal.a (python developer)

11
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

Upload: navaneethan-naveen

Post on 24-Jun-2015

203 views

Category:

Education


1 download

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)