Last active
August 29, 2015 14:10
-
-
Save clcollins/6fa7cc4b3c274d12f5f9 to your computer and use it in GitHub Desktop.
Python Subprocess Hang
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
testCmd = "/sbin/iptables -n -L %s" | |
# <snip> | |
def checkChain(): | |
cmd = testCmd % chain | |
check = subprocess.Popen(cmd, | |
shell=True, | |
stdout=subprocess.PIPE, | |
stderr=subprocess.PIPE) | |
# I don't know why, but check.stdout.read() needs to be given to something | |
# or the whole thing freezes | |
check_stdout = check.stdout.read() | |
check_error = check.stderr.read() | |
if check_error: | |
print (check_error + "\n") | |
else: | |
print "No errors" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment