#!/usr/bin/perl
#
# gethost-test - This program can be used to test whether you system is setup
#                to get it's fully qualified domain name.

use Sys::Hostname;

# Get our hostname and try to get fully qualified domain name
$host = &Sys::Hostname::hostname();
print "\nHost name found to be - $host \n\n";

($HOST) = gethostbyname($host);
print "gethostbyname() says my host name is - $HOST \n\n";

@parts = split(/\./,$HOST);

if ( $#parts + 1 >= 3 ) {
    print "I have apparently found a fully qualified domain name.\n" . 
    "\"$HOST\" should be the name given for this host in the\n" . 
    "spong.hosts configuration file.\n\n";
} else {
    print "I didn't find a fully qualified host name. You will have trouble
getting spong-server to recognize this host. You have couple of options
  1) In your \"/etc/hosts\" file make sure that the first name after your
     host's ip address is a fully qualify domain name.
  2) Name sure your host is defined in your DNS servers and make sure that
     'dns' is before 'files' on the 'hosts:' line of your \"/etc/nsswitch\"
     file or your OS's equivalent file. You want the resolver to look in
     DNS before the \"/etc/hosts\" file.\n\n";
}

