Click to See Complete Forum and Search --> : Help with bash?


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

Sixtease
03-11-2011, 04:43 AM
It would be surely interesting to trace your script and look for errors in it... surely it would make for an interesting hour, which I need to spend working. So, in order to help you, I need your help:

Give an example input and desired output
Comment each block saying what it's supposed to do and whether it works