-1

i need to read etc/named.conf file , and get the domains i want just the domains , and Order the domains line up line

zone "example.org" {
type master;
file "/var/named/example.org.db";
};


zone "example.com" {
type master;
file "/var/named/example.com.db";
};

};

i want the output like :

example.org
example.com

and i want to add this domains in www.who.is in a cgi-bin script and the output like :

example.org : www.who.is/example.org
example.com : www.who.is/example.com

i wait you

thanks to you and thanks to all users and thanks for stackoverflow.com

saba
  • 35
  • 1
  • 10

1 Answers1

0

If all the "zone" lines start in the format you posted, then this would give the desired output:

grep '^zone' /etc/named.conf | cut -d'"' -f2
Felix
  • 433
  • 4
  • 8
  • yes that is good thanks ,, please can you Explains the command grep '^zone' /etc/named.conf | cut -d'"' -f2 – saba Aug 23 '15 at 01:16
  • and how can i add the domains to www.who.is in a cgi script like www.who.is/example.com . www.who.is/example.org ????????? thanks very much – saba Aug 23 '15 at 01:18
  • Are you wanting to run a whois lookup on every domain name in your named.conf file? If you're on a Linux system, you should be able to run a `whois` utility locally. Then if you want to save all the whois lookups to files, you can do something like: `grep '^zone' /etc/named.conf | cut -d'"' -f2 | while read l; do (whois $l > /tmp/$l.whois.txt); sleep 5; done` (Note: the "sleep 5" waits 5 seconds in between queries; this is important because if you query the same whois server too quickly, it will block you for a while.) – Felix Aug 23 '15 at 04:56
  • And to explain the various commands I used: `grep '^zone' /etc/named.conf` looks for lines in /etc/named.conf where the word "zone" is at the beginning of the line. To see how this works, look up documentation or tutorials for grep and regular expressions. `| cut -d'"' -f2`: the pipe (|) sends the output from grep (which will be lines like `zone "example.com" {`) to the `cut` command. `-d'"' -f2` means "split the text at `"` characters, giving 3 sections, and give me the second section only (example.com)". `| while read l ...`: look up loops in bash or sh, and output redirection. – Felix Aug 23 '15 at 05:10
  • thanks for explain and for help thanks very much and i mean i need to see whois for all sites on server from who.is If you want to add any thing Not necessarily be whois if i want to add "hello" after all domains who iget from named.conf like example.com : hello example.org : hello etc ................. i wait you and thanks – saba Aug 23 '15 at 05:24
  • Something like this would do that: `grep '^zone' /etc/named.conf | cut -d'"' -f2 | while read l; do echo "$l : hello"; done` or for the output in your question: `grep '^zone' /etc/named.conf | cut -d'"' -f2 | while read l; do echo "$l : www.who.is/$l"; done` – Felix Aug 23 '15 at 05:50