The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
help with script output okiedokie Shell Programming and Scripting 2 03-05-2009 06:41 PM
Script that will output everything to file stuaz Shell Programming and Scripting 4 10-04-2008 08:53 AM
How redirect script output from inside of script? alex_5161 Shell Programming and Scripting 4 06-25-2008 11:27 PM
Q: Recording shell script screen output using "script" command ? lalfonso.gomez Shell Programming and Scripting 4 01-18-2007 09:31 PM
script the output with awk alexcol Shell Programming and Scripting 4 10-03-2006 07:19 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 04-14-2009
spartan22 spartan22 is offline
Registered User
  
 

Join Date: Feb 2009
Posts: 11
Digcheck SH script. Only want to see MX output.

I want to filter out all the junk and only see the Domain name and Mx records. Can't quite figure out how to get this output.

This is what i'm using to get the output.


Code:
dig mx -f domains.txt > mx.txt

This is what i see when i open the text file


Code:
; <<>> DiG 9.2.4 <<>> jjenkinsonline.com
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 2550
;; flags: qr rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 2, ADDITIONAL: 0

;; QUESTION SECTION:
;jjenkinsonline.com.		IN	MX

;; ANSWER SECTION:
jjenkinsonline.com.	3593	IN	MX	10 mailstore1.secureserver.net.
jjenkinsonline.com.	3593	IN	MX	0 smtp.secureserver.net.

;; AUTHORITY SECTION:
jjenkinsonline.com.	3581	IN	NS	ns22.domaincontrol.com.
jjenkinsonline.com.	3581	IN	NS	ns21.domaincontrol.com.

;; Query time: 0 msec
;; SERVER: 172.24.36.46#53(172.24.36.46)
;; WHEN: Tue Apr 14 16:16:26 2009
;; MSG SIZE  rcvd: 152

; <<>> DiG 9.2.4 <<>> 4miles.com
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 11463
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 13, ADDITIONAL: 1

;; QUESTION SECTION:
;4miles.com.			IN	MX

;; ANSWER SECTION:
4miles.com.		3593	IN	MX	10 mail.4miles.com.

;; AUTHORITY SECTION:
com.			172781	IN	NS	J.GTLD-SERVERS.NET.
com.			172781	IN	NS	K.GTLD-SERVERS.NET.
com.			172781	IN	NS	L.GTLD-SERVERS.NET.
com.			172781	IN	NS	M.GTLD-SERVERS.NET.
com.			172781	IN	NS	A.GTLD-SERVERS.NET.
com.			172781	IN	NS	B.GTLD-SERVERS.NET.
com.			172781	IN	NS	C.GTLD-SERVERS.NET.
com.			172781	IN	NS	D.GTLD-SERVERS.NET.
com.			172781	IN	NS	E.GTLD-SERVERS.NET.
com.			172781	IN	NS	F.GTLD-SERVERS.NET.
com.			172781	IN	NS	G.GTLD-SERVERS.NET.
com.			172781	IN	NS	H.GTLD-SERVERS.NET.
com.			172781	IN	NS	I.GTLD-SERVERS.NET.

;; ADDITIONAL SECTION:
mail.4miles.com.	3593	IN	A	64.56.35.138

;; Query time: 0 msec
;; SERVER: 172.24.36.46#53(172.24.36.46)
;; WHEN: Tue Apr 14 16:16:26 2009
;; MSG SIZE  rcvd: 289

  #2 (permalink)  
Old 04-15-2009
ZeBadger ZeBadger is offline
Registered User
  
 

Join Date: May 2008
Posts: 2
I would first suggest looking at the dig command and it's parameters to see if it will give the output you require via switches/parameters.

Else, something like this to grab A and MX records removing comments and blanks:
Quote:
dig mx -f domains.txt |egrep -v '^$|^;' |egrep '[TABSPACE]MX[TABSPACE]|[TABSPACE]A[TABSPACE]' > my.txt
swapping [TABSPACE] for [ ] with a tab and a space in it.

or something a little more condensed like...

Quote:
dig mx -f domains.txt|egrep '^[^;].*[TABSPACE]IN[TABSPACE][TABSPACE]*(MX|A)[TABSPACE]' > my.txt
Closed Thread

Bookmarks

Tags
awk, cat, dig, dns, grep

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 01:31 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0