The many different Unix varieties lead to problems writing portable shell scripts. The book Portable Shell Programming offers tips on writing portable code. Using a language such as Perl, Python, or Ruby instead may offer better portability, assuming supported systems have a supported version of the language installed.
hostname
Do not use GNU hostname(1) options on Solaris systems. The -f or --long argument will set the hostname on Solaris, instead of returning the expected fully qualified hostname as under GNU hostname.