View Single Post
  #2  
Old 1st May 2013, 19:22
K_meleonu K_meleonu is offline
Senior Member
 
Join Date: May 2006
Posts: 108
Thanks: 1
Thanked 5 Times in 4 Posts
Default

Hello again to all,
I have modifyed the script to this:
Code:
#!/bin/bash
PING=`ping -c 5 yahoo.com | grep packets | awk -F% '{print $1 $4 $6}' | cut -c 36-38`;
RASPUNS="20";
DNSACT=`tail -n 2 /etc/resolv.conf`;
DNNS1=`cat dns1`;
DNNS2=`cat dns2`;
if [[(" $PING" > "$RASPUNS") || ("$DNSACT" = "$DNS1")]];
then
{
cat dns2 > /etc/resolv.conf;
}
else 
{
cat dns1 > /etc/resolv.conf;
}
fi
It works fine exceptin when the ping answer is ping: unknown host yahoo.com. If i receive this answer the script terminates and doen not change the dns servers.

Still waiting for some help.
Thank you all in advance

Last edited by K_meleonu; 1st May 2013 at 19:55.
Reply With Quote