Hehe, As I said I found it on the net and modified just a bit, just can't get used to not declaring a variable before using it which you don't seem to have to do in bash.
Basically it looks for the word eth0 in ifconfig and directs the stderr output to the same filedescriptor as stdout, don't ask me how: http://en.tldp.org/HOWTO/Bash-Prog-I...O-3.html#ss3.1
If it can't find eth0 it echos a message and exits, if it finds it you get a connection and it exits afterwards.