Reputation: 1846
I execute a perl script with exec
via php, however I receive an error that the module Net::DNS is missing. I have installed the module as a regular user and as such is located in /home/user/perl5/i686-linux-thread-multi and I do use a full path (/usr/bin/perl) in the exec.
I've even tried to add the /home/user/perl5/i686-linux-thread-multi directory to @INC but the script still throws the error...
And I also tried to install the module with custom install path directly into /usr/lib/perl5/vendor_perl, but that didn't solve the problem either. And symlink didn't fix that either.
Here is the error message
Can't locate Net/DNS.pm in @INC (@INC contains:
/usr/lib/perl5/site_perl /usr/share/perl5/site_perl /usr/lib/perl5/vendor_perl
/usr/share/perl5/vendor_perl /usr/lib/perl5/core_perl /usr/share/perl5/core_perl
Any idea how this can be solved, sort of running out of ideas how to deal with this.
Upvotes: 0
Views: 1347
Reputation: 8895
before exec
, add:
$ENV{PERL5LIB} = "$ENV{PERL5LIB}:/home/user/perl5/i686-linux-thread-multi";
Why using use lib
wont work (for pavel's comment):
#!/usr/bin/env perl
use strict;
use warnings;
use lib "hate_you";
use Data::Dumper;
print Dumper(\@INC);
print "In sub process....\n";
exec(qq{perl -MData::Dumper -e "print Dumper(\@INC);"});
will print on my machine:
$VAR1 = [
'hate_you',
'/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',
'.'
];
In sub process....
$VAR1 = '/etc/perl';
$VAR2 = '/usr/local/lib/perl/5.14.2';
$VAR3 = '/usr/local/share/perl/5.14.2';
$VAR4 = '/usr/lib/perl5';
$VAR5 = '/usr/share/perl5';
$VAR6 = '/usr/lib/perl/5.14';
$VAR7 = '/usr/share/perl/5.14';
$VAR8 = '/usr/local/lib/site_perl';
$VAR9 = '.';
Upvotes: 2
Reputation: 3498
an alternative would be to include your personal library in your script, so it is independent from the environment set:
use lib qw(/home/user/perl5/i686-linux-thread-multi);
use Net::DNS;
Upvotes: 0