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 6865063
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T02:59:35+00:00 2026-05-27T02:59:35+00:00

Prefacing this with the text ‘just another beginner’. when you have the result of

  • 0

Prefacing this with the text ‘just another beginner’. when you have the result of a whois command via the Popen command, how do you test if its good ?

Normally when Python returns a list of whatever you can test the length of it and that has usually sufficed for me, but this is a little more arbitrary.

eg
im testing for a domains country of origin, but sometimes the domains that gethostbyaddr gives me are not recognised by the WHOIS server. So, i thought i would go with sending it an ip in case of failure but I’ve ended up with this not so pretty less than 70 characters test. Just wondering if anyone knows what the ‘standard’ way of doing this is.

w = Popen(['whois', domain], stdout=PIPE, stdin=PIPE, stderr=STDOUT)
                whois_result = w.communicate()[0]
                print len(whois_result)
                if len(whois_result) <= 70:
                        w = Popen(['whois', p_ip], stdout=PIPE, stdin=PIPE, stderr=STDOUT)
                        whois_result = w.communicate()[0]
                        print len(whois_result)
                        if len(whois_result) <= 70:
                                print "complete and utter whois failure, its you isnt it, not me."
                        test = re.search("country.+([A-Z].)",whois_result)
                        countryid = test.group(1)
  • 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-27T02:59:36+00:00Added an answer on May 27, 2026 at 2:59 am

    To answer your direct question, look for this string in the output of a whois command to see whether there was a problem…

    No match for “insert_domain_here”

    To address other meaningful issues to your task… your Popen command is going at things the hard way… you don’t need a PIPE for stdin and you can call .communicate() directly on the Popen to make this a bit more efficient… I rewrote with what I think you have in mind…

    from subprocess import Popen, PIPE, STDOUT
    import re
    
    ## Text result of the whois is stored in whois_result...
    whois_result = Popen(['whois', domain], stdout=PIPE,
        stderr=STDOUT).communicate()[0]
    if 'No match for' in whois_result:
        print "Processing whois failure on '%s'" % domain
        whois_result = Popen(['whois', p_ip], stdout=PIPE,
            stderr=STDOUT).communicate()[0]
        if 'No match for' in whois_result:
                print "complete and utter whois failure, its you isnt it, not me."
        test = re.search("country.+([A-Z].)",whois_result)
        countryid = test.group(1)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Just take this code as an example. Pretending it is an HTML/text file, if
The situation is this: We have several (19) sites that are currently configured to
I have a problem tring to write to a binary file. //This is preparing
This does not execute: create table TestTable (name text, age integer, primary key (ROWID))
We have an application that has one or more text console windows that all
I have problems with pattern. I need to process some text for example: <div>{text1}</div><span>{text2}</span>
I came across this problem while preparing for an interview and curious to know
I am preparing for my interview and came across this question: Consider that i
Apologies if this is a very basic question, but I am preparing to create
Problem: When I do something like this: for (int i = 0; i <

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.