Last active
February 15, 2018 08:58
-
-
Save mumuxme/7f354043793aa5b5fe79e525ab30ed41 to your computer and use it in GitHub Desktop.
running bash commands in python (python3.5)
This file contains hidden or 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 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