Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Problem with script not terminating under Windows XP

by biochris (Beadle)
on Sep 16, 2005 at 13:25 UTC ( [id://492605]=perlquestion: print w/replies, xml ) Need Help??

biochris has asked for the wisdom of the Perl Monks concerning the following question:

Dear Monks, I am running a 5.8.6 logon perl script on Windows XP SP2, and when I try to logoff, Win XP always promts me to end the perl script manually. The script opens a socket to a unix server, and it simply reports the currently logged in user. If you know of a generic solution for such a behavior, I would appreciate your help, otherwise I can provide some more detailed info, if necessary. Thank you very much. Chris

2005-09-16 Retitled by g0n, as per Monastery guidelines
Original title: 'Perl on Windows XP'

  • Comment on Problem with script not terminating under Windows XP

Replies are listed 'Best First'.
Re: Problem with script not terminating under Windows XP
by svenXY (Deacon) on Sep 16, 2005 at 13:45 UTC
    Hi,
    yes, some detailed information and perhaps some of your code would help a lot and would be greatly appreciated.
    To me it sounds like the script runs forever. Do you start it in a batch file?
    Regards,
    svenXY
      #! /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

Re: Problem with script not terminating under Windows XP
by radiantmatrix (Parson) on Sep 16, 2005 at 15:23 UTC

    If this is meant to be a long-running background script, perhaps you should implement it as a Windows service using Win32::Daemon. Once your app is registered with Windows as a Service, it will receive a ServiceStop() request during shutdown, which you then handle appropriately.

    <-radiant.matrix->
    Larry Wall is Yoda: there is no try{} (ok, except in Perl6; way to ruin a joke, Larry! ;P)
    The Code that can be seen is not the true Code
    "In any sufficiently large group of people, most are idiots" - Kaa's Law
      Good point. Thanks :)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://492605]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (3)
As of 2024-04-25 06:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found