Last active
November 1, 2022 20:25
-
-
Save colematt/0846ffc2ed86151053399f0ed8e6d78e to your computer and use it in GitHub Desktop.
[Run a process as a subprocess of the python interpreter] #python3
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 argparse | |
import subprocess | |
import sys | |
""" | |
Run a command and its arguments as a subprocess of the python interpreter. | |
""" | |
if __name__ == "__main__": | |
# Capture a subprocess instance | |
cp = subprocess.run( | |
sys.argv[1:], | |
stdout=subprocess.PIPE) | |
# Print the subprocess instance's output to standard output | |
print(cp.stdout.decode(),end="") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment