Created
February 12, 2023 23:59
-
-
Save bpeterso2000/1a99c1fe9d924fcdaf3a3996fc1e6531 to your computer and use it in GitHub Desktop.
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 shlex | |
import subprocess | |
import sys | |
def bash(cmd): | |
print(cmd) | |
try: | |
res = subprocess.run(shlex.split(cmd), capture_output=True, check=True) | |
except subprocess.CalledProcessError as e: | |
print(res.stderr, file=sys.stderr) | |
return res.stdout.decode('utf-8', errors='ignore') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment