--- projects/cms/source/host/ihost-perl/ihost.pl 2001/11/19 14:15:14 1.37 +++ projects/cms/source/host/ihost-perl/ihost.pl 2001/11/20 12:47:03 1.41 @@ -8,7 +8,7 @@ # a typical Unix/Linux box. # # $Author: tdb $ -# $Id: ihost.pl,v 1.37 2001/11/19 14:15:14 tdb Exp $ +# $Id: ihost.pl,v 1.41 2001/11/20 12:47:03 tdb Exp $ #------------------------------------------------------------ $| = 1; @@ -47,7 +47,11 @@ $seq_no = 1; $retry_wait = 60; # write our PID to a file -$pidfile = "/var/tmp/ihost.pid"; +# use home dir by default +$pidfile = $ENV{"HOME"}; +# or drop it in /var/tmp if we can't find HOME +$pidfile = "/var/tmp" if not defined $pidfile; +$pidfile .= "/.ihost.pid"; &write_pid(); &tcp_configure(); @@ -277,6 +281,9 @@ sub send_udp_packet() { push(@data, "packet.attributes.type=data"); push(@data, "packet.attributes.ip=$ip"); + # sort the data + @data = sort(@data); + # turn the array into some nice XML my($xml) = &make_xml("", ""); @@ -289,7 +296,7 @@ sub send_udp_packet() { print $sock $xml or die "Could not send UDP packet: $!\n"; close($sock); $seq_no++; - print "-: $xml\n"; + print "-"; return; } @@ -399,7 +406,7 @@ sub write_pid() { sub make_xml() { my($curlevel, $curline) = @_; my($xmltemp) = ""; my($curtag) = ""; my($attributes) = ""; - while(true) { + while(1) { $curline = shift(@data) if $curline eq ""; chomp $curline; if($curline =~ /^$curlevel([^\.\s]+\.)/) { $curtag=$1; @@ -415,7 +422,7 @@ sub make_xml() { } my($nextline) = $data[0]; chomp $nextline if defined $nextline; $curtag =~ s/(.*)\./$1/; - if(defined $nextline && $nextline =~ /^$curlevel$curtag\./) { + if((defined $nextline) && ($nextline =~ /^$curlevel$curtag\./)) { $curline = ""; } else {