I'm trying to write a service and need the current running directory for locating configuration files. I'm trying to use Cwd::abs_path($0) to get the directory and of course stripping off the exe name. The service seems to start, but the actual PerlSvc::Startup is never called. Everything up to that point seems to work fine ( i can see all the prints and even create a log file).
If i comment out the use Cwd line, and also hardcode the program directory, the service runs like a charm.
anyone have any ideas?
package PerlSvc;
use warnings;
use strict;
use File::Copy;
use System::System_Constants;
use Cwd qw(abs_path);
use File::Spec;
use Getopt::Long;
our $progname = Constants::APPLICATION_SERVICE_NAME_SHORT;
our $path = undef;
$path = abs_path($0);
print "Path: " . $path . "\n";
our ($volume, $directory, $fileName) = File::Spec->splitpath($path);
my $program_dir= $volume . $directory;
print "Program Dir: " . $program_dir . "\n";
our $cscc = $program_dir . "cscc.exe";
our $serviceOptionsFile = $program_dir . "serviceOptions.xml";
our $timeout = "";
our $frequency = "";
our $schedule = "";
our $scapScan = "";
our $ovalScan = "";
our $installScan = 0;
our %Config = (ServiceName => "SCC_Service",
DisplayName=> "SCC_Service",
StartType => 'auto', # auto, manual
Interactive => 1, # boolean
Description => 'Service with added console',
StartNow => 1,
Password => undef,
UserName => undef,
Dependencies => '',
Parameters => ''
);
my $logfile = $program_dir. 'SCC_Service.log';
print "Logfile: $logfile\n";
Log("\n ProgName: $progname \n");
######################################################################
+####################
sub Startup
.
.
.
.
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.