Arav
Arav

Reputation: 5247

Regarding Perl DBD::Oracle installation in local directory

  1. I want to connect with the oracle database from a perl script in solaris servier. Able to see DBI is installed but not DBD::Oracle in the current perl version 5.8.4. I dont have root acess and working on my home user id. Download the DBD-Oracle-1.50 and unzipped in the local directory where my perl script exists. I want to copy the DBD Oracle library files into a custom directory and run the script since i dont have root acess. When i read the install script in the DBD-Oracle-1.50 it's says for manuall install i need to run the below scripts . Since i dont have root access i want to copy the library modules into the local directory. Not sure how to tell these scripts to install it in the local directory where my perl script exists.

  2. Does installing DBI and DBD in a custom directory under my user id makes it work properly. Do those modules require root access to work properly? To use DBD::Oracle does oracle needs to be installed in server. My Understanding Oracle driver DBD::Oracle should take care of it.

 perl Makefile.PL
 make && make test
 make install 

>  ls -tlr /usr/perl5/vendor_perl/5.8.4/sun4-solaris-64int total 956
> -rwxr-xr-x   1 root     bin        15161 Mar 26  2005 Roadmap.pod
> -rwxr-xr-x   1 root     bin         1048 Sep  5  2006 TASKS.pod
> -rwxr-xr-x   1 root     bin       289343 Jun 26  2007 DBI.pm
> -rwxr-xr-x   1 root     bin         4608 Jun 12  2008 goferperf.pl
> -rwxr-xr-x   1 root     bin         1356 Jun 12  2008 dbixs_rev.pl
> -rwxr-xr-x   1 root     bin        58386 Apr  3  2010 SNMP.pm drwxr-xr-x   3 root     bin            7 Oct 13  2010 NetSNMP
> drwxr-xr-x   2 root     bin            3 Oct 13  2010 Win32 drwxr-xr-x
> 8 root     bin           19 Oct 13  2010 DBI drwxr-xr-x   2 root    
> bin            4 Oct 13  2010 Bundle drwxr-xr-x   6 root     other    
> 6 Oct 13  2010 auto drwxr-xr-x   3 root     bin           11 Oct 13 
> 2010 DBD
> 
> ls -ltr  /usr/perl5/vendor_perl/5.8.4/sun4-solaris-64int/DBD total 543
> -rwxr-xr-x   1 root     bin       111586 May  6  2006 Pg.pm
> -rwxr-xr-x   1 root     bin        28785 Sep 27  2006 Proxy.pm
> -rwxr-xr-x   1 root     bin         7937 Jan 25  2007 Sponge.pm
> -rwxr-xr-x   1 root     bin        42836 Feb  6  2007 DBM.pm
> -rwxr-xr-x   1 root     bin        19882 Mar 28  2007 File.pm
> -rwxr-xr-x   1 root     bin        12051 May 10  2007 ExampleP.pm
> -rwxr-xr-x   1 root     bin        43586 May 14  2007 Gofer.pm
> -rwxr-xr-x   1 root     bin         3761 Jun 15  2007 NullP.pm drwxr-xr-x   4 root     bin            4 Oct 13  2010 Gofer

Upvotes: 1

Views: 3355

Answers (2)

Anjan Biswas
Anjan Biswas

Reputation: 7932

Perl modules can be very well installed in a custom directory. This situation usually arises when you don't have root access to install the PM. Once you have installed DBI and DBD in your custom folder there are several different ways to make sure that perl is aware of this installation.

1. 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.

The syntax is the same you use for the PATH environment variables, so you separate the directories with colons on unix and with a semicolon on Windows.

Example:

# unix, bourne shell
PERL5LIB=/home/path/lib:/usr/another/path/lib; export PERL5LIB

Be aware that scripts running with -T option (taint checks) do not use that variable, so in those cases this option won't work.

2. Use '-I' command line parameter

The syntax should be something like:

perl -I /home/path/lib -I /usr/another/lib script.pl

3. Add the library path in your script

The command for including the path in your script is: use lib "path". Notice that this statement prepends "path" to the @INC array, so it's basically the same as unshift @INC, "path"

Example:

#!/usr/bin/perl
use lib "/home/path/lib";
use lib "/usr/another/lib";

Upvotes: 1

runrig
runrig

Reputation: 6524

If DBI is already installed, you should only need to install DBD::Oracle, though you might want to install a later version of DBI. You can install DBD::Oracle under your home directory, then set the PERL5LIB environment variable to that directory (or to include that directory). The long way to install is:

perl Makefile.PL PREFIX=~/perl #Or whatever sub-directory you like
make
make test
make install

Then include at least "~/perl/lib;~/perl/lib/site_perl" in PERL5LIB before running your programs (or include a 'use lib" in your programs).

You can also set certain environment variables like PERL_MM_OPT and PERL_MB_OPT so that you don't have to specify the PREFIX= on the command line (see docs for ExtUtils::MakeMaker and Module::Build). I also recommend cpanm and setting PERL_CPANM_HOME to something under your home directory.

Upvotes: 3

Related Questions