I come again with another in a continuing line of questions -- How do I find the path of the script running as a Win service? I have the following scenario.
Here is what I have tried --
File::Spec->rel2abs(curdir()), $FindBin::Bin, Cwd->cwd() all suffer from the same problem thusly: the path returned is the ostensible path to the service, of the form "C:\Windows\System32", not "E:\programs\foo", the path to foo.exe that is being run as that darned service.
I finally implemented the following solution --
The above works, however, is there a less ugly solution?@path = split(/\\/, $0); pop(@path); $path = join('\\', @path);
I have a related question --
doesn't work for obvious reasons. However, neither doesBEGIN { my $foo = 'bar'; } print $foo;
Why? Does BEGIN have its own namespace? How can I declare something once (like the $path to the script I am trying to figure out above), and have it be picked up in the BEGIN block as well as in the rest of the script or any other module that I might use in the script?my $foo = 'bar'; BEGIN { print $foo; }
Many thanks.
In reply to finding the path of the script running as Win service by punkish
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |