Solved

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

Posted on 2007-11-14
3
2,141 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
split53 challenge 7 79
Ned Perl Snippet to Read Files in Directory 5 62
Export Table to CSV - Access to CSV - using python 18 100
C# code editing and collaboration 3 99
This is an explanation of a simple data model to help parse a JSON feed
Computer science students often experience many of the same frustrations when going through their engineering courses. This article presents seven tips I found useful when completing a bachelors and masters degree in computing which I believe may he…
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
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 …

920 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now