Created
October 2, 2020 16:08
-
-
Save ACK-J/07b8bda1984ff5feb1fa6d984b4dea21 to your computer and use it in GitHub Desktop.
A function which can make a syscall in python and return stdout, stderr and the return-code
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 subprocess | |
def runcommand(cmd): | |
proc = subprocess.Popen(cmd, | |
stdout=subprocess.PIPE, | |
stderr=subprocess.PIPE, | |
shell=True, | |
universal_newlines=True) | |
std_out, std_err = proc.communicate() | |
return proc.returncode, std_out, std_err |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment