becca23 has asked for the wisdom of the Perl Monks concerning the following question:
This installed the service fine with no errors. Then I tried to use the example service code:use Win32::Daemon; %Hash = ( name => 'PerlTest', display => 'Oh my GOD, Perl is a service!', path => 'c:\perl\bin\perl.exe', user => '', pwd => '', parameters =>'c:\perl\scripts\service.pl', ); if( Win32::Daemon::CreateService( \%Hash ) ) { print "Successfully added.\n"; } else { print "Failed to add service: " . Win32::FormatMessage( Win32: +:Daemon::GetLastError() ) . "\n"; }
But I am getting an error saying that the service started and stopped, and the file is not being opened. Please Help!use Win32::Daemon; # Tell the OS to start processing the service... Win32::Daemon::StartService(); # Wait until the service manager is ready for us to continue... while( SERVICE_START_PENDING != Win32::Daemon::State() ) { sleep( 1 ); } # Now let the service manager know that we are running... Win32::Daemon::State( SERVICE_RUNNING ); # Okay, go ahead and process stuff... open (OUT, ">>C:\perl\scripts\out.txt"); print OUT "Hello, World!"; close OUT; # Tell the OS that the service is terminating... Win32::Daemon::StopService();
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Win32::daemon and Perl
by almut (Canon) on Jun 04, 2009 at 02:33 UTC | |
by afoken (Chancellor) on Jun 04, 2009 at 10:07 UTC | |
by almut (Canon) on Jun 04, 2009 at 10:24 UTC |