Monday, February 11, 2013

greping dns for a clue

i need to figure out all the sun machines i have in dns. simplifying life, i use sun, sox and sol in their names. but. i comment out stuff from time to time. what to do?
sed & grep & awk. yes!
~ sed -n '/;/!p' db.nothere | grep -e 'sun' -e 'sox' -e 'sol' | awk '{ print $1 }' > cleanorama
The sed half looks through the dns file and removes commented-out lines.
The grep part looks for exciting patterns.
The awk part strips everything and prints the first column... which is the hostname. Otherwise we'd get the whole line.
The lot of it is thrown into a file called cleanorama.

so, the reason why i was doing this is so i can figure out the names of my machines on which i need to put a patch. that patch requires my sol machines to be at a certain patch level. of course i have all my systems pubkeyed...
that being said, all i need is a nice script that'll be do a nice loop on that file.
for i in $(cat cleanorama)
do
ssh root@$i 'uname -a ; cat /etc/release |head -1' >> solrevreport
done

cat solrevreport |grep -Ev '5.8|Solaris 8|5.9|Solaris 9|5.11|Solaris 11' > sol10report
and voila all those sol 10 machines on which i can do my evil.

No comments: