Thank you for your reply and improvement. For me, the script worked even witll all caps (tested on ubuntu 12.0.4 LTS, Mandriva 2010 / 2011, Fedora 16).
The problem for wich i didn't found a solution yet is the one stated in the post above. If the answer is unknown host the script stops.
The only solution i found is to modify the host (in this case yahoo.com) with an IP address. But if that IP of yahoo.com fails then i will get a false response.
If i use the host, even if the IP fails at first check, at the second check the IP will be another one.
Again thank you for the improvement.