ericatekka
03-10-2011, 05:56 PM
Hello
I cant get the script below to work.
I only want it to show the IP's and DNS name of the IP.
Example
STORE=$1
#get stores ip bit
IPBIT=`nslookup s$STORE.internal.XXXXXXX.com.au | tail -2 | head -1 | cut -d" " -f 2 | cut -d"." -f1,2,3`
IPBIT2=`echo $IPBIT | cut -d"." -f1,2`
IPBIT3=$((`echo $IPBIT | cut -d"." -f3`))
REGIP=$IPBIT2.$IPBIT3
X=0
IPLIST=" "
while [ $X -lt 255 ]
do
IPLIST="$REGIP.$X $IPLIST"
X=$(($X+1))
done
EXP=$STORE."l"
for y in $IPLIST; do
dns=`nslookup $y | tail -2 | head -1 | cut -d"=" -f2`
if echo $dns | grep "can't" >/dev/null 2>&1
then
fdg=0
else
if [[ $dns =~ $EXP ]]
then
echo "---";
echo $y $dns
fi
fi
done
I cant get the script below to work.
I only want it to show the IP's and DNS name of the IP.
Example
STORE=$1
#get stores ip bit
IPBIT=`nslookup s$STORE.internal.XXXXXXX.com.au | tail -2 | head -1 | cut -d" " -f 2 | cut -d"." -f1,2,3`
IPBIT2=`echo $IPBIT | cut -d"." -f1,2`
IPBIT3=$((`echo $IPBIT | cut -d"." -f3`))
REGIP=$IPBIT2.$IPBIT3
X=0
IPLIST=" "
while [ $X -lt 255 ]
do
IPLIST="$REGIP.$X $IPLIST"
X=$(($X+1))
done
EXP=$STORE."l"
for y in $IPLIST; do
dns=`nslookup $y | tail -2 | head -1 | cut -d"=" -f2`
if echo $dns | grep "can't" >/dev/null 2>&1
then
fdg=0
else
if [[ $dns =~ $EXP ]]
then
echo "---";
echo $y $dns
fi
fi
done