I am in need of a script that will do many functions
Posted on 2009-04-16
I am in need of a script that will do many functions.
1. I have a list of subnets called subnets.txt
the contents of subnet.txt look like this
2. I need to run a cli that points to each of the contents in subnet.txt and run it one subnet at a time, like so
getzoneprof -u Xxx -p Xxx -a $subnet -o Orig
Once you run this I get lots of stuff, but I am only interested in on a few parameters which start from the first 4 lines of the output.
This is what it looks like:
getzoneprof -u qipman -p qipman -a 10.0.0.0/16 -o Orig
dnsServers=richm01.cmmc.sark.com P 0,hhyt.sark.com 0,6cnscuyt1.netdevice.richsark.com S 0
What I need to do from here is a bit fun, ssh into each server thats under dnsServers= ( The P and the S means primary and secondary dns servers) using my userid of richsark and password of 12345
When I ssh, there are a few prompts that I need to overcome in the script, see below attempt to ssh to a server
$ ssh firstname.lastname@example.org
Could not create directory '/home/richsark/.ssh'.
The authenticity of host 'richm01.cmmc.sark.com (22.214.171.124)' can't be established.
RSA key fingerprint is g98:t6:a8:31:7f:57:bd:b2:13:c9:0a:6a:5v:ac:73:55.
Are you sure you want to continue connecting (yes/no)? yes
Failed to add the host to the list of known hosts (/home/richsark/.ssh/known_hosts).
Total users logged in (via BoKS): 14475 (1 on this host)
Last Login 04/16/09 08:58:09 (sarkisrns.svr.us.sark.net:pts/1)
$ ( I am one)
Once I am on, I need to see if there are any files that are *.jnl in directory /opt/rich/sark
If it is, maintain a report Y/N and move on the next server
So the report ( reportcard.txt) should look something like:
From Zone 10.0.0.0/16 containting dnsserver "richm01.cmmc.sark.com" found =yes/no presence of "jnl" files
The list should continue to the next dnsserver= hhyt.sark.com and do the same. We should keep the report seperated for each subnet