Skip to content

Instantly share code, notes, and snippets.

@bpeterso2000
Created February 12, 2023 23:59
Show Gist options
  • Save bpeterso2000/1a99c1fe9d924fcdaf3a3996fc1e6531 to your computer and use it in GitHub Desktop.
Save bpeterso2000/1a99c1fe9d924fcdaf3a3996fc1e6531 to your computer and use it in GitHub Desktop.
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