Created
February 11, 2019 19:35
-
-
Save mohclips/acbb853fa4bc1641a9c18fcbf843f614 to your computer and use it in GitHub Desktop.
Example of subprocess.checkoutput and rndc
This file contains hidden or 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
def reload_zone(origin): | |
for action in ['status','freeze', 'reload', 'thaw', 'status']: | |
print('doing... rndc', action, origin) | |
cmd = ['/usr/sbin/rndc', action, origin] | |
try: | |
Out = subprocess.check_output(cmd,stderr=sys.stdout.buffer,universal_newlines=True) | |
print("{}".format(Out)) | |
except subprocess.CalledProcessError as rndcexc: | |
print("Error code {} {}".format(rndcexc.returncode, rndcexc.output)) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment