--- projects/cms/source/host/ihost-perl/ihost.pl 2001/02/05 17:38:38 1.15 +++ projects/cms/source/host/ihost-perl/ihost.pl 2001/02/27 19:14:26 1.17 @@ -10,7 +10,7 @@ # - pjm2@ukc.ac.uk # # $Author: pjm2 $ -# $Id: ihost.pl,v 1.15 2001/02/05 17:38:38 pjm2 Exp $ +# $Id: ihost.pl,v 1.17 2001/02/27 19:14:26 pjm2 Exp $ #------------------------------------------------------------ $| = 1; @@ -32,6 +32,7 @@ use vars qw ( $tcp_port $filter_addr $file_list + $fqdn ); if (@ARGV != 2) { @@ -119,6 +120,13 @@ sub tcp_configure() { print "File list obtained: $file_list\n"; + print $sock "FQDN\n"; + $response = <$sock>; + chop $response; + $fqdn = $response; + + print "FQDN returned: $fqdn\n"; + print $sock "UDPUpdateTime\n"; $response = <$sock>; chop $response; @@ -203,9 +211,23 @@ sub send_udp_packet() { my($hostname) = hostname(); $hostname =~ s/\..*$//g; - `cat /etc/resolv.conf` =~ /domain\s+([^\s]+)/; - my($domainname) = $1; - my($machine_name) = "$hostname.$domainname"; + my($resolv) = `cat /etc/resolv.conf`; + my($domainname); + my($machine_name); + if($resolv =~ /domain\s+([^\s]+)/) { + # some machines have domain in resolv.conf + $domainname = $1; + $machine_name = "$hostname.$domainname"; + } + elsif($resolv =~ /search\s+([^\s]+)/) { + # some machines have search in resolv.conf + $domainname = $1; + $machine_name = "$hostname.$domainname"; + } + else { + # we can't find out the domain + $machine_name = $hostname; + } my($ip) = inet_ntoa(scalar(gethostbyname($hostname)) || 'localhost'); # Build the XML packet this way, as we can clearly