/usr/share/doc/python-getdns-doc/examples/simple.py is in python-getdns-doc 1.0.0~b1-1build4.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | #!/usr/bin/env python
#
"""
simple.py
A simple example to query a domain name and print out addresses
associated with it.
"""
import sys, getdns
hostname = sys.argv[1]
ctx = getdns.Context()
extensions = { 'return_both_v4_and_v6' : getdns.EXTENSION_TRUE }
try:
results = ctx.address(name=hostname, extensions=extensions)
except:
e = sys.exc.info()[0]
print(str(e))
sys.exit(1)
status = results.status
if status == getdns.RESPSTATUS_GOOD:
for addr in results.just_address_answers:
print (addr['address_data'])
else:
print("{0}: getdns.address() returned error: {1}".format((hostname, status)))
|