Hello Brains,
I was trying to develop a script that would do nslookup using both name and ip of server and format the output and store in an output file. Please find the script below.
#!/usr/bin/ksh
cat $1 | tr "[:upper:]" "[:lower:]" |
while read ip name
do
ERROR="$(nslookup $ip | grep can't | awk -F" " '{print $5}' > /dev/null 2>/dev/null;echo $?)"
if [[ $ERROR -eq 0 ]]
then
FQDN=`nslookup $name.symc | grep Name | awk '{print $2}'`
echo $ip $FQDN $name >> $1.hosts
else
FQDN=`nslookup $ip | grep Name | awk '{print $2}'`
echo $ip $FQDN $name >> $1.hosts
fi
done
I would be running the script by providing filename as argument. The content of filename would be in format <ip address> <host name>.
While I execute the script, it throws error... (pfb)
# ./dnsscript test
./dnsscript: syntax error at line 25 : `'' unmatched
The 25th line is
FQDN=`nslookup $ip | grep Name | awk '{print $2}'`
Could you please help me to get this script running perfectly ?
Many Thanks,
Praveen