instead of using exec in our script to do an nslookup, is there an easy way to write it programmatically in PHP, Python, or Ruby?
Socket Class in Ruby. See this answer.