Please excuse me as I am new to perl and still struggling to grasp some ideas and need your help. I tried running the above example it doesn't give any error and ran fine but everytime I try to run it from the commandline it executes the following:
else { die "Nothing to do\n"; }
and no service is created. Is there any parameter needs to pass while running the script. And what exactly is the following for:
my %opt; GetOptions ( \%opt, "run", "install", "remove", "start", "stop", "restart", "pause", "resume|continue", );
What exactly is GetOptions for. I tried to modify thie above scripty and put the following code in the else part:
else { #die "Nothing to do\n"; &removeService(); &installService(); my $cmd = 'net start $serviceConfig{name}'; my $results = `$cmd`; if($!) { &debug("Net Start returned error: $@\n" . $results); die "ERROR"; } #don't know what is this for my %context = { last_state => SERVICE_STOPPED, count => 0, start_time => time(), }; Win32::Daemon::StartService( \%context, 3000 ); exit(); }
now I run the script and service gets created and can start,stop,resume etc.. the service under services. I don't if it's the right way. Any comments will be really appeciated. Thanks

In reply to Re^4: Perl script as windows service by rockets12345
in thread Perl script as windows service by rockets12345

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.