what's wrong with my bash script?

hi,

please point out what's wrong with my script. im feeding it a list containing fqdn, sit should ssh into each and verify that atleast one of its virtual backup ip resolves into one of its virtual hostnames .. anyway the objective shows in the script... however, im having problems in the
innermost if condition.. "else" wont get executed.

#!/bin/bash -x

for i in `cat $1`
do
        _HOSTNAME=`echo $i |cut -d"." -f1`
        /usr/bin/ssh $i "
                echo $_HOSTNAME;
                for i in `/sbin/ifconfig -a | grep 172\.39 | awk '{print $2}'`
                do
                        if [[ -n `nslookup $i | grep $_HOSTNAME | awk '{print $2}'` ]]
                        then echo "backup interface OK"
                        else echo "backup interface NOT OK"
                        fi
                done
        " >> $1.out 2>/dev/null
done

TIA!

aww man... no replies until now? :frowning:

in both for loop, you are using same index "i".
So in the if condition, second "i" will be used, Is this the one you want ?

changing the variable to another ('j' for example) hangs at this point:

++ awk '{print $2}'

yes the variable is a problem, but i think there's something else with the way i did it.

please suggest.

could you please post the latest code and the debug o/p ?
Please state your current issue as well.