Skip to content

Instantly share code, notes, and snippets.

@clcollins
Last active August 29, 2015 14:10
Show Gist options
  • Save clcollins/6fa7cc4b3c274d12f5f9 to your computer and use it in GitHub Desktop.
Save clcollins/6fa7cc4b3c274d12f5f9 to your computer and use it in GitHub Desktop.
Python Subprocess Hang
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