vik-y
1/11/2015 - 1:14 PM

Run Shell Scripts from Python like subprocesses

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]