Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Just a Script to Help Out

Status
Not open for further replies.

RShaw

MIS
Oct 23, 2002
10
0
0
US
The company I work for seems to hire installers that think setting up SCO UNIX servers as DHCP Hosts is a great idea ( thus they are installers and not technicians !!!!)

So I wrote this to help discover what IP addresses from the defined DHCP Pool are active at the time the script is run.

I am sending this to basically give back to the group as you have helped me countless times!

#!/bin/ksh
#Script to discover devices using DHCP addresses as assigned by SCO UNIX DHCP Host
#
B=`more /etc/dhcpd.conf | grep "subnet" | nawk '{ print $2 }' | nawk -F . '{ print $1"."$2"."$3 }'`
s=`more /etc/aasd.conf | grep "${B}" | nawk -F . '{print $1"."$2"."$3 }'`
i=`more /etc/aasd.conf | grep "${B}" | nawk -F . '{print $4}'| nawk -F - '{ print $1 }'`
e=`more /etc/aasd.conf | grep "${B}" | nawk -F - '{print $2}'| nawk -F . '{ print $4 }'`
#
#B=Base IP Subnet Used By DHCP as Defined in /etc/dhcpd.conf
#s=First 3 Octets of Base IP as definded in /etc/aasd.conf
#i=Initial Device Octet as defined in /etc/aasd.conf
#e=Ending Device Octet as defined in /etc/aasd.conf
#
#
#Prepares output file /tmp/addys.out for writing
if [ -f /tmp/addys.out ]; then
rm /tmp/addys.out
else
touch /tmp/addys.out
chmod 777 /tmp/addys.out
fi
#
#Pings DHCP Scope to see whose active
#
while [[ ${i} -lt ${e} ]]
do
ping -c 3 ${s}.${i} >> /tmp/addys.out
i=`expr ${i} + 1 `
done
 
RSHAW:
You should turn your offerring into a FAQ :)
That'll make it easier to find, when it's needed!
 
My DHCP FAQ...

DHCP - DON'T USE IT

End of DHCP FAQ
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top