Output shell command in python -
def run_command(command): p = subprocess.popen(command, stdout=subprocess.pipe, stderr=subprocess.stdout) return p.communicate() on running : command = ("git clone " + repo).split() run_command(commmnd) everything working.but when try run multiple commands got error. command = ("git clone www.myrepo.com/etc:etc && cd etc && git stash && git pull).split() run_command(command) use subprocess.check_output() shell=true option, heed security warning re untrusted inputs if applies you. import subprocess command = 'git clone www.myrepo.com/etc:etc && cd etc && git stash && git pull' try: output = subprocess.check_output(command, shell=true) except subprocess.calledprocesserror exc: print("subprocess failed return code {}".format(exc.returncode)) print("message: {}".format(exc.message)) after output