Skip to content

Instantly share code, notes, and snippets.

@vik-y
Last active August 29, 2015 14:13
Show Gist options
  • Save vik-y/5312921b7093e6324e81 to your computer and use it in GitHub Desktop.
Save vik-y/5312921b7093e6324e81 to your computer and use it in GitHub Desktop.
Run Shell Scripts from Python like subprocesses
import subprocess
def runCommand(comm):
'''
Using the subprocess library this runs the command passed
'''
proc = subprocess.Popen(comm.split(), stdout=subprocess.PIPE)
outputstr = ''
for line in proc.stdout.readlines():
outputstr+=line.rstrip()+"\n"
return outputstr[:-1]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment