Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1103897
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T01:24:24+00:00 2026-05-17T01:24:24+00:00

I have a DNS script which allow users to resolve DNS names by typing

  • 0

I have a DNS script which allow users to resolve DNS names by typing website names on a Windows command prompt.

I have looked through several guides on the DNS resolve but my script can’t still seem to resolve the names (www.google.com) or (google.com) to IP address.

The script outputs an error of

Traceback (most recent call last):
  File "C:\python\main_menu.py", line 37, in ?
    execfile('C:\python\showdns.py')
  File "C:\python\showdns.py", line 3, in ?
    x = input ("\nPlease enter a domain name that you wish to translate: ")
  File "<string>", line 0, in ?
NameError: name 'google' is not defined

The code:

import socket

x = input ("\nPlease enter a domain name that you wish to translate: ")

print ("\n\nThe IP Address of the Domain Name is: "+socket.gethostbyname_ex(x))

x = raw_input("\nSelect enter to proceed back to Main Menu\n")
if x == '1': 
execfile('C:\python\main_menu.py')

Please give advice on the codes. Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T01:24:25+00:00Added an answer on May 17, 2026 at 1:24 am

    input() is the wrong function to use here. It actually evaluates the string that the user entered.

    Also gethostbyname_ex returns more than just a string. So your print statement would also have failed.

    In your case this code should work:

    import socket
    
    x = raw_input ("\nPlease enter a domain name that you wish to translate: ")  
    
    data = socket.gethostbyname_ex(x)
    print ("\n\nThe IP Address of the Domain Name is: "+repr(data))  
    
    x = raw_input("\nSelect enter to proceed back to Main Menu\n")  
    if x == '1':   
        execfile('C:\python\main_menu.py')  
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an aprox 1000 line-script which loops through all servers in AD. The
I have currently a DNS Reverse lookup script which works however there is a
I have a Windows 2003 DNS server that forwards on to OpenDNS. I want
I have a Windows server that is intermittently losing the ability to lookup DNS
I have a Windows server that is intermittently losing the ability to lookup DNS
I have a String like below: <script language=JavaScript type=text/javascript src=http://dns.net/adj/myhost.com/index;size=5x10;zipc=12345;myzon=north_west;|en;tile=10;ord=7jkllk456?></script> I want to access
I have a script which allows me to lookup for a hostname after inputting
I would like to have a local DNS server which I can configure in
I have a symfony project which, because of DNS issues, is http://<project-name>/ locally, but
I have tried using this script to change the ipaddress on windows xp and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.