Hi all,
I have written the following script which will try pinging to almost 24 nodes and when the connectivity is down it sends me an alert saying the node is down. It also gets me a trace route information and a contact information.
When i run this script manually it actually works. But when i have assigned it in cronjob and when it gets executed it throws up mails for all 24 nodes saying all are done which is not the case when executing it manually. I suspect that the if condition b=$? seems not to be working in this case or in other words the value of b goes greater than zero which is again not happening int eh case of running the script manually. Can you suggest me on this?
Can you assist me in this. I am a bit confused on this as i have checked all the paths i have referred in the scripts.
NODEINFODIR=/ndm1/work/scripts/testdir/venki
cd $NODEINFODIR
i=1
while [ $i -le 24 ]
do
k=`cat /ndm1/work/scripts/testdir/venki/iplist|head -$i|tail -1`
echo $k
v=`ping $k|grep alive`
b=$?
echo $b >>dhadha
if
[ $b -gt 0 ]
then
traceroute $k > "$NODEINFODIR/tracerouteinformationof$k.txt"
cat $NODEINFODIR/filename | grep $k | cut -f1-8 -d '' > "Contactinformationfor$knode.txt"
(echo "Node $k is down"; uuencode Contactinformationfor$knode.txt Contactinformationfor$knode.txt;uuencode tracerouteinformationof$k.txt
tracerouteinformationof$k.txt)| mailx -s " Node connectivity "
venkita.venkatarama@gmail.com
else
echo " The connectivity is live "
fi
i=`expr $i + 1`
done