#!/bin/cshset FILE = "/var/dhcpd/var/db/dhcpd.leases"set LeaseCount = `grep -c "binding state active" $FILE`echo "Active LeaseCount: $LeaseCount"if ($LeaseCount > 0) then set LINE = ( `grep -n "binding state active" $FILE | cut -d: -f1` ) foreach L ($LINE) echo "##################" # set EL = `expr $L + 8` set CL = `expr $L - 5` while ( $CL < `expr $L + 8` ) if ( `sed -n "$CL p" $FILE | cut -d ' ' -f1` == "lease" ) then echo IP: `sed -n "$CL p" $FILE | cut -d ' ' -f2` endif if ( `sed -n "$CL p" $FILE | cut -d ' ' -f3` == "starts" ) then echo Start: `sed -n "$CL p" $FILE | cut -d ' ' -f5,6` endif if ( `sed -n "$CL p" $FILE | cut -d ' ' -f3` == "ends" ) then echo Ende: `sed -n "$CL p" $FILE | cut -d ' ' -f5,6` endif if ( `sed -n "$CL p" $FILE | cut -d ' ' -f3` == "hardware" ) then echo MAC: `sed -n "$CL p" $FILE | cut -d ' ' -f5` endif if ( `sed -n "$CL p" $FILE | cut -d ' ' -f3` == "client-hostname" ) then echo Name: `sed -n "$CL p" $FILE | cut -d ' ' -f4-` endif if ( `sed -n "$CL p" $FILE | cut -d ' ' -f3` == "set" ) then echo Device: `sed -n "$CL p" $FILE | cut -d ' ' -f6-` endif if ( `sed -n "$CL p" $FILE | cut -d ' ' -f1` == "}" && $CL > $L ) then set CL = `expr $CL + 8` endif @ CL++ end end exit 1else exit 0endif