LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Small Whois Script (https://www.linuxquestions.org/questions/programming-9/small-whois-script-781526/)

tarken 01-11-2010 01:44 PM

Small Whois Script
 
I am trying to write a script that will do a whois on a domain but only print out the email addresses and if there is not one listed than say something like "No Address on file" or something. Does anyone have any ideas on how to do that?

What I have been trying to do is something like:

whois iamned.com | grep "Tech Email" > file -v

Any help would be greatly appreciated!

Tarken

rweaver 01-11-2010 02:42 PM

The only significant problem you'll have is that most registrants list the email information in a different format.

For instance, perform a 'whois google.com' and a 'whois yourdomain.com' and a 'whois -h whois.tucows.com sourceforge.net'

Code:

#!/bin/bash
whois $1 | egrep '\w+([._-]\w)*@\w+([._-]\w)*\.\w{2,4}'

That will pull the email addresses, but you may or may not get valid information (A few registers I tried it against I got email addresses with no indication of what they were tied to contact wise.)

You might be further ahead to make a full script to parse whois outputs in perl, ruby, or python.

tarken 01-11-2010 02:52 PM

Quote:

Originally Posted by rweaver (Post 3822870)
The only significant problem you'll have is that most registrants list the email information in a different format.

For instance, perform a 'whois google.com' and a 'whois yourdomain.com' and a 'whois -h whois.tucows.com sourceforge.net'

Code:

#!/bin/bash
whois $1 | egrep '\w+([._-]\w)*@\w+([._-]\w)*\.\w{2,4}'

That will pull the email addresses, but you may or may not get valid information (A few registers I tried it against I got email addresses with no indication of what they were tied to contact wise.)

You might be further ahead to make a full script to parse whois outputs in perl, ruby, or python.


What does '\w+([._-]\w)*@\w+([._-]\w)*\.\w{2,4}' do?

rweaver 01-11-2010 03:08 PM

Quote:

Originally Posted by tarken (Post 3822879)
What does '\w+([._-]\w)*@\w+([._-]\w)*\.\w{2,4}' do?

It's an expression that matches (most) email addresses:

Code:

core:~/test/test23$ cat wi.sh
#!/bin/bash
whois $1 | egrep '\w+([._-]\w)*@\w+([._-]\w)*\.\w{2,4}'
core:~/test/test23$ ./wi.sh slashdot.org
Registrant Email:hostmaster@geek.net
Admin Email:dns-admin@geek.net
Tech Email:dns-tech@geek.net
core:~/test/test23$


Habitual 09-08-2013 07:31 AM

It may not necessarily be "Tech Email" across all registrars.


All times are GMT -5. The time now is 05:39 PM.