Difference between revisions of "Get-root-zone"

From CDOT Wiki
Jump to: navigation, search
Line 4: Line 4:
  
 
<pre>
 
<pre>
#!/bin/bash
+
#!/bin/bash
# Created by: Raymond Chan
+
# Created by: Raymond Chan
# for OPS535
+
# for OPS535
# version 0.5
+
# (c) 2016 - update for new wiki site
# (c) 2010
+
url=http://zenit.senecac.on.ca/wiki/index.php/Domainreg
url=http://zenit.senecac.on.ca/wiki/index.php/Domainreg
 
 
if [ ! -f raw.txt ]
 
then
 
    echo "Gettting wiki file from the web ..." >&2
 
    wget -O raw.txt $url
 
fi
 
 
buffer=$(cat raw.txt| grep ^'</td><td>')
 
 
nl=$(echo "$buffer"|wc -l)
 
a=0
 
b=5
 
 
while [ $a -lt $nl ]
 
do
 
    stuff=$(echo "$buffer"| head -"$b" | tail -5|nl|sed -e "s/<\/td><td>/x/g")
 
    #  echo "$stuff"
 
    fields=$(echo "$stuff"|sed -e "s/ //g"|awk -Fx {'print $2'})
 
  
    parameters=$(echo $fields)
+
if [ ! -f raw.txt ]
    paratest=$(echo $parameters | sed -e "s/ //g")
+
then
    cc=$(echo $paratest | wc -w)
+
echo "Gettting wiki file from the web ..." >&2
        # echo "paratest cc is $cc"
+
wget -O raw.txt $url
 +
fi
 +
 
 +
buffer=$(cat raw.txt| grep ^'<td>')
 +
 
 +
nl=$(echo "$buffer"|wc -l)
 +
a=0
 +
b=6
  
    if [ $cc -gt 0 ]
+
while [ $a -lt $nl ]
    then   
+
do
        #echo $a $parameters
+
stuff=$(echo "$buffer"| head -"$b" | tail -5|nl|sed -e "s/<td>/x/g")
        #read yyy   
+
# echo "$stuff"
        set $parameters
+
fields=$(echo "$stuff"|sed -e "s/ //g"|awk -Fx {'print $2'})
  
        if [ "$1" != "" -a "$3" != "" -a "$4" != "" ]
+
parameters=$(echo $fields)
        then
+
cc=$(echo $parameters | wc -w)
 +
        # echo "paratest cc is $cc"
  
            echo -e "${1}. \tIN \tNS \t$4."
+
if [ "$cc" -gt 0 ]
            echo -e "${4}. \tIN \tA \t$3"
+
then
            echo " "
+
#echo $a $parameters
 +
#read yyy
 +
set $parameters
 +
if [ "$1" != "domainname" ]
 +
then
 +
if [ "$1" != "" -a "$3" != "" -a "$4" != "" ]
 +
then
  
        fi
+
echo -e "${1}. \tIN \tNS \t$4."
    fi
+
echo -e "${4}. \tIN \tA \t$3"
 +
echo " "
 +
 +
fi
 +
fi
 +
fi
  
    let a=a+5
+
let a=a+6
    let b=b+5
+
let b=b+6
  
    #read xxx
+
#read xxx
done
+
done
 
</pre>
 
</pre>

Revision as of 16:40, 19 October 2016


Sample Bash script for extracting Domain Registration wiki page Domainreg and create a root zone file.

#!/bin/bash
# Created by: Raymond Chan
# for OPS535
# (c) 2016 - update for new wiki site
url=http://zenit.senecac.on.ca/wiki/index.php/Domainreg

if [ ! -f raw.txt ]
then
	echo "Gettting wiki file from the web ..." >&2
	wget -O raw.txt $url
fi

buffer=$(cat raw.txt| grep ^'<td>')

nl=$(echo "$buffer"|wc -l)
a=0
b=6

while [ $a -lt $nl ]
do
	stuff=$(echo "$buffer"| head -"$b" | tail -5|nl|sed -e "s/<td>/x/g")
	#  echo "$stuff"
	fields=$(echo "$stuff"|sed -e "s/ //g"|awk -Fx {'print $2'})

	parameters=$(echo $fields)
	cc=$(echo $parameters | wc -w)
        # echo "paratest cc is $cc"

	if [ "$cc" -gt 0 ]
	then	
		#echo $a $parameters
		#read yyy	
		set $parameters
		if [ "$1" != "domainname" ]
		then
			if [ "$1" != "" -a "$3" != "" -a "$4" != "" ]
			then

	 			echo -e "${1}. \tIN \tNS \t$4."
	 			echo -e "${4}. \tIN \tA \t$3"
				echo " "
	
			fi
		fi
	fi

	let a=a+6
	let b=b+6

	#read xxx
done