Solved

Can't locate Win32/Service.pm in @INC (@INC contains:

Posted on 2007-11-14
3
2,153 Views
Last Modified: 2008-02-01
I am trying to use same perl script both on Windows and Unix enviornment, it works on windows fine but I get below error on Unix

Can't locate Win32/Service.pm in @INC (@INC contains: /home/s/lib /usr/opt/perl5/lib/5.8.2/aix-thread-multi /usr/opt/perl5/lib/5.8.2 /usr/opt/perl5/lib/site_perl/5.8.2/aix-thread-multi /usr/opt/perl5/lib/site_perl/5.8.2 /usr/opt/perl5/lib/site_perl .) at test.pm line 25.
BEGIN failed--compilation aborted

on test.pm at line 25 I have this entry
use Win32::Service;

I have to comment out above line in order to make it work on Unix, is there a way that I could run the same perl script with having 2 verions (windows and Unix) of it?
I would appreciate your help
0
Comment
Question by:khanzada19
  • 2
3 Comments
 
LVL 18

Accepted Solution

by:
Morcalavin earned 125 total points
ID: 20281123
I don't know the best solution, but I use this on a few scripts.

#!/usr/bin/perl
BEGIN
{
        if($^O eq "MSWin32")
        {
                require Win32::Service;
        }
}
0
 
LVL 18

Expert Comment

by:Morcalavin
ID: 20281128
It's worth noting that Win32::Service is only going to work on windows systems, so if you try to make use of it in unix it's going to croak.
0
 
LVL 39

Expert Comment

by:Adam314
ID: 20281443
The code for Morcalavin will let your script run, but there will likely be other errors if you use any functions from the Win32::Service module.

What is it that the script does on windows?  What do you want it to do on unix?
What windows calls services are what unix calls daemons.  Do you want to monitor a daemon process?
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
C# application error "Parameter Is Not Valid". 3 135
sp_configure 'external scripts enabled', 1; 7 113
add projects t working set in maven 2 44
Perl Snippet to Parse String 1 39
This is about my first experience with programming Arduino.
This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question