Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Oratcl - Oracle environment variables

216 views
Skip to first unread message

Avi

unread,
May 14, 2014, 10:01:50 AM5/14/14
to
Hi

I am following the guidelines to add the Oracle variables in the program.
However, it does not work.
Here is my program:

#!/bin/ksh
# the next line restarts using tclsh \
exec /usr/bin/tclsh "$0" "$@"

lappend auto_path /usr/share

set ::env(ORACLE_BASE) /usr/vendor/pkg/oracle
set ::env(ORACLE_HOME) /usr/vendor/pkg/oracle/product/current
set ::env(LD_LIBRARY_PATH) /usr/vendor/pkg/oracle/product/current/lib

package require Oratcl

exit 0

The error I get is:

Oratcl_Init(): Failed to load /usr/vendor/pkg/oracle/product/current/lib/libclntsh.so with error libnnz11.so: cannot open shared object file: No such file or directory

while executing
"load /usr/share/Oratcl4.5/libOratcl4.5.so"
("package ifneeded Oratcl 4.5" script)
invoked from within
"package require Oratcl"
(file "./ora.tcl" line 24)

The took the assigned values from the shell.
When these variables are set and exported in the shell, everything works well.

OS: RHEL 6.4 x86_64
Oracle client: 11.2.0.2.0
Oratcl: 4.5

What am I doing wrong?

Thanks
Avi

Eric

unread,
May 14, 2014, 2:25:44 PM5/14/14
to
Sadly, that is not the way the Environment and ::env work. Your script
will inherit the shell's environment variables, but if one you need is
not there putting it in ::env will not help.

The Oracle code that oratcl calls does not know who is calling or even
that ::env exists, and uses getenv() or similar which gets exactly the
environment that was passed to the process in the first place, i.e. the
one from the shell.

The contents of ::env would be passed to a new process called from your
Tcl, but oratcl and oracle itself will be running in the same process.

I think the best you can do is to set the variables in a wrapper shell
script that calls your Tcl script.

BTW, you shouldn't need ORACLE_BASE and it's likely (but not certain)
that you don't need LD_LIBRARY_PATH.

Eric
--
ms fnd in a lbry

Avi

unread,
May 15, 2014, 8:38:17 AM5/15/14
to
On Wednesday, May 14, 2014 2:25:44 PM UTC-4, Eric wrote:
Eric

Thanks for looking into this and your insight.
While the evidence seems to prove your point, the Oratcl Manual published by its maintainer, Mr. Todd Helfter, advises using the env() approach.
I did "solve" the problem with a wrapper script.
However, now I have two programs to deliver to the users.

I hope Mr. Helfter will provide his comments on this.

Thanks again
Avi

David Zolli

unread,
May 15, 2014, 1:40:18 PM5/15/14
to
IIRC Oracle installation advises to set this variables. So, in a perfect world, Oratcl shouldn't have to care of this.
--
David Zolli - Kroc

Anton Osennikov

unread,
Jun 26, 2014, 1:38:05 AM6/26/14
to
15.05.2014 18:38, Avi пїЅпїЅпїЅпїЅпїЅ:

> While the evidence seems to prove your point, the Oratcl Manual published by its maintainer, Mr. Todd Helfter, advises using the env() approach.
> I did "solve" the problem with a wrapper script.

If you set ::env(ORACLE_HOME) before "package require Oratcl", it works.

$ tclsh
% unset ::env(ORACLE_HOME)
% package require Oratcl
can't read "env(ORACLE_HOME)": no such variable
% set ::env(ORACLE_HOME) /opt/oracle/home1
/opt/oracle/home1
% package require Oratcl
4.5

--
Best regards, Anton.

0 new messages