in reply to Re: Problem with script not terminating under Windows XP
in thread Problem with script not terminating under Windows XP
#! /usr/bin/perl -w use strict; use IO::Socket; my ( $local_host, $iaddr, $host, $port, $user, $paddr, $proto, $line, +$sock_handle ); if($ARGV[0]) { $user=$ARGV[0]; } else { $user = getlogin; } ###################end client.head ###################start Make generated $local_host = "host_name"; $iaddr = 192.168.254.33; $host = '192.168.254.33'; $port = 7797; ###################end Make generated ###################start client.tail $|=1; print "PLEASE do NOT close this window, simply minimize it.\n"; print "Thanks,\n\tDan, your friendly system administrator\n"; #this must be set to the ip address of the accounts server. $paddr = sockaddr_in($port, $iaddr); $proto = getprotobyname('tcp'); $sock_handle = IO::Socket::INET->new(Proto => "tcp", PeerAddr => $host, PeerPort => $port) or die "can't connect to port $port on $host: $!"; $sock_handle->autoflush(1); #send computer and username print $sock_handle "$user\n"; print $sock_handle "$local_host\n"; #register signalhandler $SIG{INT} = \&end; #$SIG{TERM} = \ #now update the server once a while while() { #sleep for 10 minutes sleep(10*60); #notify the server that we are alive print $sock_handle "alive\n" } sub end { my $signame = shift; print $sock_handle "quit\n"; close $sock_handle || die "close: $!"; exit(0); }
Can you help?? :)
Edit: g0n - added code tags
|
|---|