Skip to content

Instantly share code, notes, and snippets.

@mumuxme
Last active February 15, 2018 08:58
Show Gist options
  • Select an option

  • Save mumuxme/7f354043793aa5b5fe79e525ab30ed41 to your computer and use it in GitHub Desktop.

Select an option

Save mumuxme/7f354043793aa5b5fe79e525ab30ed41 to your computer and use it in GitHub Desktop.
running bash commands in python (python3.5)
import subprocess
def run_sh(sh, stderr=subprocess.STDOUT, stdout=None):
assert isinstance(sh, str)
args = ["bash", "-c", sh]
subprocess.run(args, stderr=stderr, stdout=stdout, check=True)
run_sh("echo hello > hello.txt")
run_sh("ls -l")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment