File: gethost-test

package info (click to toggle)
spong 2.7.7-19
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 1,880 kB
  • ctags: 1,224
  • sloc: perl: 6,640; sh: 2,247; makefile: 237
file content (31 lines) | stat: -rwxr-xr-x 1,209 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/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";
}