Last active
August 29, 2015 14:13
-
-
Save vik-y/5312921b7093e6324e81 to your computer and use it in GitHub Desktop.
Run Shell Scripts from Python like subprocesses
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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