Fix shell script bugs
Work on IPv6