views:

45

answers:

3

I'm a python newbie and I don't understand why it won't read my IP and ADDR variables in the function dns.zone.query(IP, ADDR)???

import dns.query
import dns.zone
import sys

IP = sys.stdin.readline()
ADDR = sys.stdin.readline()


z = dns.zone.from_xfr(dns.query.xfr(IP , ADDR))
names = z.nodes.keys()
names.sort()
for n in names:
    print z[n].to_text(n)

It works when I pass an actual IP and Domain, but not with the variables... I don't get what's wrong?

+2  A: 

Try sys.stdin.readline().strip(). You need to remove the newlines.

robert
+6  A: 

readline() will include a trailing newline. You can use sys.stdin.readline().strip()

Bob
+2  A: 

I would try with:

IP = sys.stdin.readline().strip()
ADDR = sys.stdin.readline().strip()

Add some prints after the variables to debug it:

print '_%s_' % IP
print '_%s_' % ADDR
systempuntoout