1

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?

1
  • Do you get an error message? Have you tried debugging it to see on which line it goes wrong? Commented Aug 19, 2010 at 20:47

3 Answers 3

6

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

Sign up to request clarification or add additional context in comments.

Comments

2

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

Comments

2

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.