LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 01-11-2010, 01:44 PM   #1
tarken
Member
 
Registered: Jan 2010
Location: Portland
Distribution: Kubuntu
Posts: 82

Rep: Reputation: 16
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
 
Old 01-11-2010, 02:42 PM   #2
rweaver
Senior Member
 
Registered: Dec 2008
Location: Louisville, OH
Distribution: Debian, CentOS, Slackware, RHEL, Gentoo
Posts: 1,833

Rep: Reputation: 167Reputation: 167
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.

Last edited by rweaver; 01-11-2010 at 02:44 PM.
 
Old 01-11-2010, 02:52 PM   #3
tarken
Member
 
Registered: Jan 2010
Location: Portland
Distribution: Kubuntu
Posts: 82

Original Poster
Rep: Reputation: 16
Quote:
Originally Posted by rweaver View Post
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?
 
Old 01-11-2010, 03:08 PM   #4
rweaver
Senior Member
 
Registered: Dec 2008
Location: Louisville, OH
Distribution: Debian, CentOS, Slackware, RHEL, Gentoo
Posts: 1,833

Rep: Reputation: 167Reputation: 167
Quote:
Originally Posted by tarken View Post
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$
 
Old 09-08-2013, 07:31 AM   #5
Habitual
LQ Veteran
 
Registered: Jan 2011
Location: Abingdon, VA
Distribution: Catalina
Posts: 9,374
Blog Entries: 37

Rep: Reputation: Disabled
It may not necessarily be "Tech Email" across all registrars.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
small script spx2 Linux - Newbie 10 12-13-2005 12:35 PM
small script Kassel Programming 2 11-19-2004 04:22 AM
help with a very small script hamish Linux - General 3 06-09-2004 02:10 AM
Need help with very small script. Franklin Programming 8 10-14-2003 12:37 PM
Small Script msj Linux - Newbie 2 08-27-2001 06:59 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

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

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration