CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Intermediate:
Can't find DBD/mysql.pm - cPanel

 



nasirjavaid
New User

Jan 30, 2016, 3:08 AM

Post #1 of 2 (2747 views)
Can't find DBD/mysql.pm - cPanel Can't Post

Dear All,

I am trying to install autoresponder365 script on my cpanel hosted machine. but when I run script it gives below error

Software error:

install_driver(mysql) failed: Can't locate DBD/mysql.pm in @INC (@INC contains: lib /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 (eval 16) line 3.
Perhaps the DBD::mysql perl module hasn't been fully installed,
or perhaps the capitalisation of 'mysql' isn't right.
Available drivers: DBM, ExampleP, File, Gofer, Proxy, SQLite, Sponge.
at install.cgi line 164

Now I do not have shell access so can't do it by linux cli and checking in 'perl modules' portion of cpanel they say:

Location of Your Perl Module(s)

Path: /home/username/perl


Using Your Perl Module(s)

You will need to add /home/username/perl to the include path.
You can do this by adding the following code to your script:

BEGIN {
my $b__dir = (-d '/home/username/perl'?'/home/username/perl':( getpwuid($>) )[7].'/perl');
unshift @INC,$b__dir.'5/lib/perl5',$b__dir.'5/lib/perl5/x86_64-linux-thread-multi',map { $b__dir . $_ } @INC;
}



I have tried it by inserting 'begin' code in start of my install.cgi script but then it doesn't get called. How can I include my path in @INC?

Any help will be highly appreciated.

Thanks.


Zhris
Enthusiast

Jan 30, 2016, 9:20 AM

Post #2 of 2 (2728 views)
Re: [nasirjavaid] Can't find DBD/mysql.pm - cPanel [In reply to] Can't Post

I haven't used cpanel in a while, but you have taken the right approach. Could you expand on "doesn't get called", do you receive the same "Can't locate DBD/mysql.pm" error? The begin block is best placed immediately below the shebang line of every perl script. In fact a proper approach would be to use an @INC manipulating module such as lib, but this isn't important. Dump the @INC array and check that the paths generated exist, theres a possibility you will need to modify the begin block root path / b__dir to suit your directory structure. Check that DBD/mysql.pm exists down one of the generated paths, if not then ensure you install it via the perl modules portion of cpanel.


Code
/usr/bin/perl 

BEGIN
{
my $b__dir = (-d '/home/username/perl'?'/home/username/perl':( getpwuid($>) )[7].'/perl');
unshift @INC,$b__dir.'5/lib/perl5',$b__dir.'5/lib/perl5/x86_64-linux-thread-multi',map { $b__dir . $_ } @INC;
}

for ( @INC )
{
my $exists = -e $_ ? ' ' : ' not ';
print "'$_' does${exists}exist\n";
}


Chris


(This post was edited by Zhris on Jan 30, 2016, 9:30 AM)

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives