0

Hello,

I need to seperate multiple domains by having and not having A records.

I have created a shell script like below, but it is not working, as the $? is same (0) for both the dig commands that have and not have A records.

*************************

!/bin/bash

for dom in cat /home/xxxx/domainslist.txt
do

result= dig +noall +answer $dom

if [ "$result" != '') ];then

echo $dom >> /home/xxxx/havingA.txt

else

echo $dom >> /home/xxxx/havingNoA.txt

fi

done

**************************

Please help me if there is any other way we can do this. Thank you.

Edited by jino: correction

1
Contributor
2
Replies
3
Views
5 Years
Discussion Span
Last Post by jino
0

There is a small syntax error in my previous code and it is corrected as

if [ "$result" != '' ];then

The issue persists. Please help me if anyone have a better idea of doing this.

Edited by jino: correction

0

:-) I have figured it out.

#!/bin/bash

for dom in cat /home/xxxx/domainslist.txt

do

result=$(dig +noall +answer $domains | awk '{print $5}')

if [ "$result" != '' ];then

echo "$dom" >> /home/xxxx/havingA.txt

else

echo "$dom" >> /home/xxxx/havingNoA.txt

fi

done

This will dig the domains one by one that is listed in the domainslist.txt and will seperate by having Address record and not.

Thanks for everyone who tried. :-)

Edited by jino: correction

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.