LoadRunner Web Tours cannot locate systemPaths - perl

Having problems setting up LoadRunner Web Tours. Getting the following error in error.log.
Can't locate systemPaths in #INC (#INC contains:
C:/strawberry/perl/site/lib C:/strawberry/perl/vendor/lib
C:/strawberry/perl/lib) at C:/WebTours/cgi-bin/welcome.pl line 16.,
referer: http://localhost:8080/WebTours/
I have setup those links in Env Variable Paths. systemPaths is not a file in there. In the welcome.pl, there is "require "systemPaths";" line, I do not know perl. Thanks

[I'm assuming C:\WebTours\cgi-bin\systemPaths.pm exists.]
Add the following to C:\WebTours\cgi-bin\welcome.pl:
use FindBin qw( $RealBin );
use lib $RealBin;
The module search path (#INC) used to include the current work directory (.), that many scripts incorrectly used as a proxy for the directory in which the script resides. So welcome.pl was buggy, which became very apparent with recent versions of Perl.

Related

plink- Can't locate .pl in #INC error while running a perl script located on a remote linux server using a python program from windows

I'm trying to run a perl script that is located in a remote linux server from windows using the python program. I'm using the subprocess.call method.
This is the python line of code
returnCd = subprocess.call(['plink', '-ssh', \
'%s#%s' %('******','*****.***.com'), '-pw', '****', \
'perl', '/apps/CACSGDEV/springbatch/perlscript/DEBTOR_VERIFICATION.pl'], \
shell=True)
And this is what i see in the console (broken over lines for readability)
Can't locate ENVRC.pl in #INC (#INC contains: /usr/local/lib64/perl5
/usr/local/share/perl5 /usr/lib64/perl5/vendor_perl
/usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .)
at /apps/CACSGDEV/springbatch/perlscript/DEBTOR_VERIFICATION.pl line 16.
The file DEBTOR_VERIFICATION.pl has the following # line 16
require "ENVRC.pl";
The file ENVRC.pl is in the same path as that of the DEBTOR_VERIFICATION.pl. Can anyone please suggest?
The program DEBTOR_VERIFICATION.pl is directly executed and thus it doesn't need to have its directory in #INC. On the other hand, when a file need be loaded via require (or use, which uses require) then it is precisely the directories in #INC that are searched for it. Since /apps/.., where ENVRC.pl resides, is not there the file cannot be found.
You need to add that directory to #INC and a good way to do it is via lib pragma
use warnings;
use strict;
...
use lib "/apps/CACSGDEV/springbatch/perlscript";
...
But if this program (DEBTOR_VERIFICATION.pl) and the required file ENVRC.pl will always stay in the same directory it is better to use FindBin instead of hard coding the path
use warnings;
use strict;
...
use FindBin qw($RealBin);
use lib $RealBin;
In either case the files in that directory can now be found by use and require (and do).
The DEBTOR program works when executed right from its directory, in older Perls, since the . (the current working directory) used to be included in #INC by default. We see that this is the case from #INC printed in the error message. So . gets searched and ENVRC.pl is found.
Relying on that has really always been a bad practice, but as of perl v5.26.0 (perldelta) (May 2017) the . directory is not in #INC anymore.
So you should add the above use lib statement to the DEBTOR... program anyway.

My Perl code does not seem to work with .lib?

I'm new to both Perl and its feature of .lib.
I made this simple subroutine and saved it as a file with an extension of .lib
sub shorterline {
print "Content-type: text/html\n\n";
}
1;
As I tried to insert the subroutine into the Perl file with an extension of .cgi below, it doesn't work somehow:
#!/usr/bin/perl
require 'mysubs.lib';
&shorterline;
print "Hello, world!";
I gave the .cgi the chmod permission, but the .cgi still doesn't work, what seem to be the problem ?
Your descriptions of what the problem is are rather unclear.
it doesn't work somehow
the .cgi still doesn't work
Without knowing what problems you're seeing, it's hard to know what the problem is. But I tried copying your code and running the program from the command line and I got this error message:
Can't locate mysubs.lib in #INC (#INC contains: ...)
So I think you are using a recent version of Perl and are running up against this change:
Removal of the current directory (".") from #INC
The perl binary includes a default set of paths in #INC. Historically it has also included the current directory (".") as the final entry, unless run with taint mode enabled (perl -T). While convenient, this has security implications: for example, where a script attempts to load an optional module when its current directory is untrusted (such as /tmp), it could load and execute code from under that directory.
Starting with v5.26, "." is always removed by default, not just under tainting. This has major implications for installing modules and executing scripts.
If this is the problem, then you can fix it by adding the script's directory to #INC as follows:
use FindBin qw( $RealBin );
use lib $RealBin;
before your call to require. If that doesn't solve your problem, perhaps you would consider sharing a little more detail about the problems that you are experiencing.

Apache doesn't see pm file

I have installed Apache 2.2 and strawberry perl. I have textxx.pm. And I prepare simple script
#!/usr/bin/perl
use textxx;
print("HelloWorld!");
When I run it via cmd it works. When I run it via web browser I get and error:
Can't locate textxx.pm in #INC (#INC contains: C:/strawberry/perl/site/lib C:/strawberry/perl/vendor/lib C:/strawberry/perl/lib .)
It's weird because script without "use" works.
My module is located at the same directory as script
You are trying to use the textxx.pm perl module.. but it is not found while running through apache, if you remove the use line it will obviously work since it's not looking for the module.
a quick fix, if your textxx.pm is in let's say C:/strawberry/perl/site/lib then just add this at the top of your script:
#!/usr/bin/perl
use lib "C:/strawberry/perl/site/lib";
use textxx;
print("HelloWorld!");
Lack of permission could be the issue, but I'm betting the problem is that you're expecting Perl to look in the directory containing the script for the module. Perl doesn't do that, at least not by default.
It worked from the console because you set the current work directory happened to the be the same as the script, but that's not the case when you're running it through apache.
To tell Perl to look in the same directory as the script, add the following because use textxx;:
use Cwd qw( realpath );
use File::Basename qw( dirname );
use lib dirname(realpath($0));

Can't locate Connection.pm in #INC (#INC contains: /usr/local/lib/perl/5.14.2 /etc/perl /usr/local/share/perl/5.14.2 ....) at ./select.cgi at line

I am trying my hands for the first time in -> Apache - Perl (CGI) on Ubuntu.
The Apache server is working fine in the folder /var/www for the default index.html file. But since I want to run a CGI script, I also installed (just in case) DBI, as suggested by some forums. I set the permissions for complete access to my cgi-bin folder in which the select.cgi script resides. I tried tweaking the select.cgi script multiple times redirecting the library to the Perl library, but to no avail. I modified the httpd.conf file and set the directory path to the select.cgi folder. That didn't work. I also defined ScriptAlias, and set it to the working directory. That didn't work either.
Does anyone have any helpful pointers. Thanks.
This is not exact solution that you want but the overall idea is like below.
How to resolve Cant locate xxxx.pm in #INC path problem
By default perl looks for modules in the standard library path and the current directory.
Sometimes you need to use some modules that are installed in non standard locations; there are several ways to deal with this situation:
To check whether your module is in #INC path use.
Example:
perl -e 'use SOAP::Lite;'
perl -e 'use Error;'
If you run these commands on a system that has SOAP::Lite and Error installed, Perl will simply return from these commands without printing any output.
To check current standard library path use:
perl -le 'print foreach #INC'
If you have the administrative privileges, then best solution is to install the module in any of the system defined library path.
Set the environment variable PERL5LIB
Perl will look for modules in the directories specified in PERL5LIB environment variable before looking in the standard library and current directory.
So you can set this variable to locate your modules.
Example:
# For unix like systems
PERL5LIB=/home/path/lib:/usr/another/path/lib; export PERL5LIB
Note: separate the directories with colons on unix and with a semicolon on Windows.
IF you are running your code from command line then use -I parameter. The syntax should be something like.
perl -I /home/path/lib -I /usr/another/lib script.pl
And you can also Add the library path in your script
The command for including the path in your script is: use lib path.
Example:
#!/usr/bin/perl
use lib "/home/path/lib";
use lib "/usr/another/lib";
use MyCustomModule;
In a comment, you gave information that contradicts what you gave originally. The latter information appears to be more reliable, so I'll use it.
I believe you said the path to the module is
/usr/lib/perl5/vendor_perl/5.8.5/foo/bar/Connection.pm
and that the error message you got (with line breaks added) is:
Can't locate foo/bar/Connection.pm in #INC (#INC contains:
/etc/perl
/usr/local/lib/perl/5.14.2
/usr/local/share/perl/5.14.2
/usr/lib/perl5
/usr/share/perl5
/usr/lib/perl/5.14
/usr/share/perl/5.14
/usr/local/lib/site_perl
.
/usr/lib/perl5/vendor_perl/5.8.5/foo/bar/
) at ...
You did something like
use foo::bar::Connection;
or
require "foo/bar/Connection.pm";
Perl looked for
/etc/perl/foo/bar/Connection.pm
/usr/local/lib/perl/5.14.2/foo/bar/Connection.pm
...
/usr/lib/perl5/vendor_perl/5.8.5/foo/bar/foo/bar/Connection.pm
But none of those are
/usr/lib/perl5/vendor_perl/5.8.5/foo/bar/Connection.pm
It's simple to fix. Add the following to your script:
use lib '/usr/lib/perl5/vendor_perl/5.8.5';
The other possible fix is to use
use Connection;
instead of
use foo::bar::Connection;
Which fix is the correct fix depends on what that package line in side the module looks like. If you find package foo::bar::Connection;, you need to modify #INC (as shown with use lib, for example). If you findpackage Connection;, you need to change theuse` directive.

"Can't locate inc/nph-globals.pl in #INC (#INC contains: ......" ERROR for my PERL site

I am setting up perl site on XAMPP local server. I have placed the code at proper place and change first line of all .pl and .cgi files as per the path. i.e.
#!"D:\xampp\perl\bin\perl.exe"
for my case. Still I am getting error like
Can't locate inc/nph-globals.pl in
#INC (#INC contains:
D:/xampp/perl/site/lib/
D:/xampp/perl/lib
D:/xampp/perl/site/lib .
D:/xampp/apache) at
D:/xampp/htdocs//cgi-bin/webscripts/nph-home.pl
line 9.
Please suggest.
I suspect the file is located at
D:/xampp/htdocs/cgi-bin/webscripts/inc/nph-globals.pl
If so, it doesn't work because your script incorrectly assume the current working directory is set to the directory that contains the executing script, namely
D:/xampp/htdocs/cgi-bin/webscripts
The following code will address that issue:
use lib 'D:/xampp/htdocs/cgi-bin/webscripts';
Or generically,
use Cwd qw( realpath );
use File::Basename qw( dirname );
use lib dirname(realpath($0));
Looks to me that on the file that give this error, it cannot locate the file inc/nph-globals.pl. probably in that file, you need to specify something like
#!"D:\xampp\perl\bin\perl.exe" -I <path_to_inc_nph-globals.pl>