Re: How to set LD_LIBRARY_PATH

2010-05-29 Thread Paul Johnson
On Fri, May 28, 2010 at 06:14:38AM -0400, John Scoles wrote:

> You will have to set those values before your modules load.
> 
> So you should stick them in the BEGIN and that should work

... except where it doesn't, such as on Solaris for example.  Here,
LD_LIBRARY_PATH (at least) really does need to be set before the process
starts.  You can do this by writing a shell wrapper, or re-execing your
perl script if the value is not already set.

You're using linux and I'm not sure if this sort of messing about is
required there.


> http://www.compuspec.net/reference/language/perl/BEGIN_and_END.shtml
> 
> cheers
> John Scoles
> 
> On Fri, May 28, 2010 at 3:45 AM, newbie01 perl wrote:
> 
> > Hi all,
> >
> > Can someone advise how to set LD_LIBRARY_PATH from within the Perl scripts?
> >
> > If I set LD_LIBRARY_PATH from the command line, all is okay
> >
> > [oracle ~]$ perl -e 'use DBD::Oracle; print $DBD::Oracle::VERSION,"\n";'
> > Can't load
> >
> > '/oracle/product/db/11.1/perl/lib/site_perl/5.8.3/x86_64-linux-thread-multi/auto/DBD/Oracle/Oracle.so'
> > for module DBD::Oracle: libclntsh.so.11.1: cannot open shared object file:
> > No such file or directory at
> > /usr/lib64/perl5/5.8.5/x86_64-linux-thread-multi/DynaLoader.pm line 230.
> > at -e line 1
> > Compilation failed in require at -e line 1.
> > BEGIN failed--compilation aborted at -e line 1.
> > [oracle ~]$ export LD_LIBRARY_PATH=/oracle/product/db/11.1/lib
> > [oracle ~]$ perl -e 'use DBD::Oracle; print $DBD::Oracle::VERSION,"\n";'
> > 1.15
> >
> > But if I do the following instead in the Perl script, it does not work? How
> > to set the LD_LIBRARY_PATH then?
> >
> > $ENV{ORACLE_HOME}=$ORACLE_HOME;
> > $ENV{ORACLE_SID}=$ORACLE_SID;
> > $ENV{PATH}="$ORACLE_HOME/bin:$PATH";
> > $ENV{LD_LIBRARY_PATH}="$ORACLE_HOME/lib";
> >
> > FYI, the script is to run from a cron which is why am setting
> > LD_LIBRARY_PATH in the script.
> >
> > Any response will be very much appreciated. Thanks in advance.
> >
> 
> --
> Catch Alex & Sheeri at ODTUG/Kaleidoscope - June 27 - July 1. 
> Hear Sheeri speak or email eve...@pythian.com to meet with Pythian.

-- 
Paul Johnson - p...@pjcj.net
http://www.pjcj.net


Re: How to set LD_LIBRARY_PATH

2010-05-29 Thread Marilyn Sander

On May 28, 2010, at 9:33 AM, Paul Johnson wrote:

> On Fri, May 28, 2010 at 06:14:38AM -0400, John Scoles wrote:
> 
>> You will have to set those values before your modules load.
>> 
>> So you should stick them in the BEGIN and that should work
> 
> ... except where it doesn't, such as on Solaris for example.  Here,
> LD_LIBRARY_PATH (at least) really does need to be set before the process
> starts.  You can do this by writing a shell wrapper, or re-execing your
> perl script if the value is not already set.
> 
> You're using linux and I'm not sure if this sort of messing about is
> required there.
> 
> 
>> http://www.compuspec.net/reference/language/perl/BEGIN_and_END.shtml
>> 
>> cheers
>> John Scoles
>> 
>> On Fri, May 28, 2010 at 3:45 AM, newbie01 perl 
>> wrote:
>> 
>>> Hi all,
>>> 
>>> Can someone advise how to set LD_LIBRARY_PATH from within the Perl scripts?
>>> 
>>> If I set LD_LIBRARY_PATH from the command line, all is okay
>>> 
>>> [oracle ~]$ perl -e 'use DBD::Oracle; print $DBD::Oracle::VERSION,"\n";'
>>> Can't load
>>> 
>>> '/oracle/product/db/11.1/perl/lib/site_perl/5.8.3/x86_64-linux-thread-multi/auto/DBD/Oracle/Oracle.so'
>>> for module DBD::Oracle: libclntsh.so.11.1: cannot open shared object file:
>>> No such file or directory at
>>> /usr/lib64/perl5/5.8.5/x86_64-linux-thread-multi/DynaLoader.pm line 230.
>>> at -e line 1
>>> Compilation failed in require at -e line 1.
>>> BEGIN failed--compilation aborted at -e line 1.
>>> [oracle ~]$ export LD_LIBRARY_PATH=/oracle/product/db/11.1/lib
>>> [oracle ~]$ perl -e 'use DBD::Oracle; print $DBD::Oracle::VERSION,"\n";'
>>> 1.15
>>> 
>>> But if I do the following instead in the Perl script, it does not work? How
>>> to set the LD_LIBRARY_PATH then?
>>> 
>>> $ENV{ORACLE_HOME}=$ORACLE_HOME;
>>> $ENV{ORACLE_SID}=$ORACLE_SID;
>>> $ENV{PATH}="$ORACLE_HOME/bin:$PATH";
>>> $ENV{LD_LIBRARY_PATH}="$ORACLE_HOME/lib";
>>> 
>>> FYI, the script is to run from a cron which is why am setting
>>> LD_LIBRARY_PATH in the script.
>>> 
>>> Any response will be very much appreciated. Thanks in advance.
>>> 

Have you considered doing a require instead of a use.  With require, the 
loading is done at run time, and would be governed by the setting of 
LD_LIBRARY_PATH, at the time the require statement is executed.  Just set 
LD_LIBRARY_PATH before doing the require.
--Marilyn




RE: How to set LD_LIBRARY_PATH

2010-05-29 Thread Bobak, Mark
I'd argue you want to use a shell wrapper anyhow, because rather than setting 
those variables explicitly, you ought to do something like:
export ORACLE_SID=your_sid
export ORAENV_ASK=NO
. oraenv

and Oracle will set it all for you, and if/when something changes or is 
upgraded, your code will continue to do the right thing.

-Mark

From: Paul Johnson [p...@pjcj.net]
Sent: Friday, May 28, 2010 12:33
To: John Scoles
Cc: newbie01 perl; beginners; dbi-users
Subject: Re: How to set LD_LIBRARY_PATH

On Fri, May 28, 2010 at 06:14:38AM -0400, John Scoles wrote:

> You will have to set those values before your modules load.
>
> So you should stick them in the BEGIN and that should work

... except where it doesn't, such as on Solaris for example.  Here,
LD_LIBRARY_PATH (at least) really does need to be set before the process
starts.  You can do this by writing a shell wrapper, or re-execing your
perl script if the value is not already set.

You're using linux and I'm not sure if this sort of messing about is
required there.


> http://www.compuspec.net/reference/language/perl/BEGIN_and_END.shtml
>
> cheers
> John Scoles
>
> On Fri, May 28, 2010 at 3:45 AM, newbie01 perl wrote:
>
> > Hi all,
> >
> > Can someone advise how to set LD_LIBRARY_PATH from within the Perl scripts?
> >
> > If I set LD_LIBRARY_PATH from the command line, all is okay
> >
> > [oracle ~]$ perl -e 'use DBD::Oracle; print $DBD::Oracle::VERSION,"\n";'
> > Can't load
> >
> > '/oracle/product/db/11.1/perl/lib/site_perl/5.8.3/x86_64-linux-thread-multi/auto/DBD/Oracle/Oracle.so'
> > for module DBD::Oracle: libclntsh.so.11.1: cannot open shared object file:
> > No such file or directory at
> > /usr/lib64/perl5/5.8.5/x86_64-linux-thread-multi/DynaLoader.pm line 230.
> > at -e line 1
> > Compilation failed in require at -e line 1.
> > BEGIN failed--compilation aborted at -e line 1.
> > [oracle ~]$ export LD_LIBRARY_PATH=/oracle/product/db/11.1/lib
> > [oracle ~]$ perl -e 'use DBD::Oracle; print $DBD::Oracle::VERSION,"\n";'
> > 1.15
> >
> > But if I do the following instead in the Perl script, it does not work? How
> > to set the LD_LIBRARY_PATH then?
> >
> > $ENV{ORACLE_HOME}=$ORACLE_HOME;
> > $ENV{ORACLE_SID}=$ORACLE_SID;
> > $ENV{PATH}="$ORACLE_HOME/bin:$PATH";
> > $ENV{LD_LIBRARY_PATH}="$ORACLE_HOME/lib";
> >
> > FYI, the script is to run from a cron which is why am setting
> > LD_LIBRARY_PATH in the script.
> >
> > Any response will be very much appreciated. Thanks in advance.
> >
>
> --
> Catch Alex & Sheeri at ODTUG/Kaleidoscope - June 27 - July 1.
> Hear Sheeri speak or email eve...@pythian.com to meet with Pythian.

--
Paul Johnson - p...@pjcj.net
http://www.pjcj.net




Some DBI question -

2010-05-29 Thread newbie01 perl
Hi,

Am trying out DBI for Oracle and just want to know if for example, I need to
include column formatting stuff etc., is it best to just put them into a
.sql file and then execute the .sql file instead of placing them in the Perl
DBI script?

Also, is there anyway to sort of "hide" the password somehow when using Perl
DBI?

Any advise or feedback will be very much appreciated.

Thanks in advance.