-3

I've read about Subprocess module from python documentation and from Stackoverflow as well ! But i am unable to implement the concept ! Like for example :

enter image description here

So how can I execute following command line using python ?

hashcode55
  • 5,622
  • 4
  • 27
  • 40
Harsh kumar
  • 89
  • 1
  • 2
  • 9

1 Answers1

0

You can do it using subprocess.call

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

Here * is the bufsize, 0 means unbuffered, 1 means line buffered, any other positive value means use a buffer of approximately that size. The default value for bufsize is 0 (unbuffered).

Example (from the docs)-

from subprocess import call
subprocess.call(["ls", "-l"])

Source - https://docs.python.org/2/library/subprocess.html

hashcode55
  • 5,622
  • 4
  • 27
  • 40
  • I have read this answer before as well could you just write the exact line ? I mean the cmd instruction is mentioned above ! Ps what is * ? – Harsh kumar Jun 12 '16 at 10:34
  • if there are multiple commands then separate them in the list , `subprocess.call("your command", shell = True)`... I can't test it as I'm using unix based system. I edited the answer too. – hashcode55 Jun 12 '16 at 10:43
  • Thanks @hashcode55 ! It is working. I was looking for this short answer -> subprocess.call("your command",shell=True) – Harsh kumar Jun 12 '16 at 10:53