in reply to Re: Turn a perl script into a Win32 Service
in thread Turn a perl script into a Win32 Service

ikegami,
I ended up going with the SrvAny tool. I wanted to share the following for those who might come across this post in the future.

There doesn't seem to be a resource toolkit for Vista available for download. You can use the 2003 toolkit but you will get an error indicating "known compatibility issues". Additionally, you will get a cryptic "permission denied - contact your system administrator" even if you are logged in as an administrator. You will need to launch the command prompt with administrator rights. Finally, modifying the registry leaves quite a bit to be desired. If you need to have your service dependent on another service or some other "advanced" configuration - look at another service and use it as a starting point.

Cheers - L~R

  • Comment on Re^2: Turn a perl script into a Win32 Service

Replies are listed 'Best First'.
Re^3: Turn a perl script into a Win32 Service
by Limbic~Region (Chancellor) on Oct 14, 2008 at 14:16 UTC
    All,
    It looks like SrvAny is a bust. The service starts and perl is in the process table, but it doesn't do anything. Even unbuffered output to STDERR in a BEGIN block doesn't show up until after stopping the service and then that's all it does. Still looking for solutions.

    Cheers - L~R

        BrowserUk,
        Here is an idea of what I am talking about (actual code is at home):
        #!/usr/bin/perl BEGIN { open(STDERR, '>', 'C:/app_name/err.log' or die $!; select STDERR; $| = 1; # un-necessary, I know print STDERR "hello world\n"; } use lib 'C:/app_name'; use strict; use warnings; use My::App; my $app = My::App->new(cfg => 'C:/app_name/app.cfg') or die "Didn't ge +t past this point\n"; print STDERR "Ok, got here\n"; while ($app->run_ok) { print STDERR "Inside while loop\n"; $app->do_things(); $app->rest_for_a_while(); } print STDERR "finishing up now\n";

        When I start the service, the err.log file is created but is 0 bytes. After 5 minutes or so, I stop the service and the following output shows up in the err.log file (hello world and Ok, Got here)

        Cheers - L~R

      Maybe you'll have better luck using wperl.exe instead of perl.exe.
        ikegami,
        Maybe you'll have better luck using wperl.exe instead of perl.exe.

        Interesting thought. I wonder where you came up with it?

        This application currently doesn't write to STDOUT, STDERR, or read input from STDIN. It does write information to a SQLite database as well as launch external GUI applications (Firefox via WWW::Selenium as well as interface Outlook via Win32::API. It runs fine from the command line but not as a service (no work is performed). I am happy to give wperl.exe a try later but I am not sure why it would work where perl.exe fails.

        Are you thinking that it is specifically my application and not just any perl script that won't work using SrvAny with 5.10 on Vista?

        Cheers - L~R