View Single Post
  #3  
Old 6th May 2013, 15:55
sjau sjau is offline
Local Meanie
 
Join Date: Apr 2006
Location: Switzerland
Posts: 1,149
Thanks: 4
Thanked 56 Times in 52 Posts
Default

here's a bit an improved version (bash-wise)

Code:
#!/bin/bash
# Don't use ALLCAPS for custom variables. By convention only Environmental vars are ALLCAPS
makeping=$(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 [[ "${makeping}" -gt "${raspuns}" || "${dnsact}" = "${dns1}" ]]
then
    cat "dns2" > "/etc/resolv.conf"
else 
    cat "dns1" > "/etc/resolv.conf"
fi
As for the problem, I have no idea.
__________________
"Common sense is not as common as commonly believed" by sjau

Auto-Install Script for ISPConfig and Horde on a Vanilla Debian Stable

Need more Repos for Ubuntu? Repository Generator
Need more Repos for Debian? Debian Repository Generator
Reply With Quote