Skip to content

Instantly share code, notes, and snippets.

@freinold
Last active April 8, 2020 11:35
Show Gist options
  • Save freinold/5d13ee176b59d3b20a25612d53c4ab44 to your computer and use it in GitHub Desktop.
Save freinold/5d13ee176b59d3b20a25612d53c4ab44 to your computer and use it in GitHub Desktop.
python3 bash call (Subprocess)
import subprocess
def _bash(cmd: str) -> str:
logging.debug("Bash Command: {0}".format(cmd))
output: str = subprocess.run(
cmd,
shell=True,
check=True,
executable="/bin/bash",
capture_output=True,
text=True
).stdout
logging.debug("Command Output: {0}".format(output))
return output
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment