Networking Forums

Networking Forums > Computer Networking > Linux Networking > Running dynamically linked CGIs?

Reply
Thread Tools Display Modes

Running dynamically linked CGIs?

 
 
Ramon F Herrera
Guest
Posts: n/a

 
      07-03-2003, 06:46 AM
This is about my first non-trivial cgi-bin program.
It is written in C and uses the Oracle OCI.
The program runs fine when executed from the Unix
shell, but when I try to execute it from the web,
this error message is the result:


claimsof.cgi: error while loading shared libraries:
libclntsh.so.9.0: cannot open shared object file:
No such file or directory


It seems that the Apache server doesn't have access
to the Oracle libraries. I tried linking the application
statically, but that doesn't seem to be an option (?)
with OCI. Next, I looked at the httpd config file and
copied the library in question (libclntsh.so.9.0) to the
directory /etc/httpd/modules/. (Am I in the right
direction?) The problem now is that I am not sure about
what the entry should look like. There is an example:

# Example:
# LoadModule foo_module modules/mod_foo.so

So I figure that the entry should be something like this:


LoadModule what_the_heck_goes_here modules/libclntsh.so.9.0


I tried looking inside (nm *.so) the .so files but no luck.

So, how can I run my cgi-bin OCI program from the web?

TIA,

-Ramon F. Herrera
 
Reply With Quote
 
 
 
 
Telemachus
Guest
Posts: n/a

 
      07-03-2003, 10:13 AM
Have you a symbolic link for libclntsh.so to /usr/lib

alternatively
set LIBPATH in apache's .profile to include the path to the libclntsh.

there should be no need to include that module as an apache load.
"Ramon F Herrera" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) om...
> This is about my first non-trivial cgi-bin program.
> It is written in C and uses the Oracle OCI.
> The program runs fine when executed from the Unix
> shell, but when I try to execute it from the web,
> this error message is the result:
>
>
> claimsof.cgi: error while loading shared libraries:
> libclntsh.so.9.0: cannot open shared object file:
> No such file or directory
>
>
> It seems that the Apache server doesn't have access
> to the Oracle libraries. I tried linking the application
> statically, but that doesn't seem to be an option (?)
> with OCI. Next, I looked at the httpd config file and
> copied the library in question (libclntsh.so.9.0) to the
> directory /etc/httpd/modules/. (Am I in the right
> direction?) The problem now is that I am not sure about
> what the entry should look like. There is an example:
>
> # Example:
> # LoadModule foo_module modules/mod_foo.so
>
> So I figure that the entry should be something like this:
>
>
> LoadModule what_the_heck_goes_here modules/libclntsh.so.9.0
>
>
> I tried looking inside (nm *.so) the .so files but no luck.
>
> So, how can I run my cgi-bin OCI program from the web?
>
> TIA,
>
> -Ramon F. Herrera



 
Reply With Quote
 
Ramon F Herrera
Guest
Posts: n/a

 
      07-03-2003, 10:27 AM
I am going to answer part of my own posting.

(E-Mail Removed) (Ramon F Herrera) wrote in message news:<(E-Mail Removed). com>...
[...]
> It seems that the Apache server doesn't have access
> to the Oracle libraries. I tried linking the application
> statically, but that doesn't seem to be an option (?)
> with OCI. Next, I looked at the httpd config file and
> copied the library in question (libclntsh.so.9.0) to the
> directory /etc/httpd/modules/. (Am I in the right
> direction?) The problem now is that I am not sure about
> what the entry should look like. There is an example:
>
> # Example:
> # LoadModule foo_module modules/mod_foo.so
>
> So I figure that the entry should be something like this:
>
>
> LoadModule what_the_heck_goes_here modules/libclntsh.so.9.0
>


The LoadModule has _nothing_ to do with this, dummy :-)

Those modules are linked to the Apache server itself, and not
to the cgi-bin or other apps that may be exec'd by Apache.

The error message above was fixed simply by adding

$ORACLE_HOME/lib

To the /etc/ld.so.conf file and redoing the .so cache.

Having said that, I am not out of the woods yet. The
new error message says:

nclaims:
FAILED: OCIInitialize()
nclaims:
FAILED: init_handles()
nclaims:
There was an error on 'OCILogon'
[Thu Jul 3 03:39:02 2003] [error] [client x.x.x.x]
Premature end of script headers:
/home/ramon/public_html/cgi-bin/claimsof.cgi

(the same programs runs flawlessly from the Unix shell).

Now it looks like the OCI .so library is being found
at link time, but not at execute time??

TIA,

-Ramon
 
Reply With Quote
 
Ramon F Herrera
Guest
Posts: n/a

 
      07-03-2003, 08:11 PM
As several of you correctly guessed, the problem turned
out to be a missing environment variable ($ORACLE_HOME).

Boy, there's really more than one way to skin a cat.
My solution was to modify the cgi-bin program as
shown below. That'll do for now.

Later on, I'll look into the NG suggestions.

Thanks to all!

-Ramon



void
setupEnvironment()
{

// if Oracle is homeless, give him a good home

if (!getenv("ORACLE_HOME")) {
setenv("ORACLE_HOME", "/home/oracle/product/9.2.0", 0);
fromWeb = TRUE;
}
else
fromWeb = FALSE;

return;
}

[...]

if (fromWeb)
printf("Content-type: application/pdf\n\n");




(E-Mail Removed) (Ramon F Herrera) wrote in message

> Having said that, I am not out of the woods yet. The
> new error message says:
>
> nclaims:
> FAILED: OCIInitialize()
> nclaims:
> FAILED: init_handles()
> nclaims:
> There was an error on 'OCILogon'
> [Thu Jul 3 03:39:02 2003] [error] [client x.x.x.x]
> Premature end of script headers:
> /home/ramon/public_html/cgi-bin/claimsof.cgi
>
> (the same programs runs flawlessly from the Unix shell).
>
> Now it looks like the OCI .so library is being found
> at link time, but not at execute time??
>
> TIA,
>
> -Ramon

 
Reply With Quote
 
Tim X
Guest
Posts: n/a

 
      07-07-2003, 08:30 AM
>>>>> "Ramon" == Ramon F Herrera <(E-Mail Removed)> writes:

Ramon> I am going to answer part of my own posting.
Ramon> (E-Mail Removed) (Ramon F Herrera) wrote in message
Ramon> news:<(E-Mail Removed). com>...
Ramon> [...]
>> It seems that the Apache server doesn't have access to the Oracle
>> libraries. I tried linking the application statically, but that
>> doesn't seem to be an option (?) with OCI. Next, I looked at the
>> httpd config file and copied the library in question
>> (libclntsh.so.9.0) to the directory /etc/httpd/modules/. (Am I in
>> the right direction?) The problem now is that I am not sure about
>> what the entry should look like. There is an example:
>>
>> # Example: # LoadModule foo_module modules/mod_foo.so
>>
>> So I figure that the entry should be something like this:
>>
>>
>> LoadModule what_the_heck_goes_here modules/libclntsh.so.9.0
>>


Ramon> The LoadModule has _nothing_ to do with this, dummy :-)

Ramon> Those modules are linked to the Apache server itself, and not
Ramon> to the cgi-bin or other apps that may be exec'd by Apache.

Ramon> The error message above was fixed simply by adding

Ramon> $ORACLE_HOME/lib

Ramon> To the /etc/ld.so.conf file and redoing the .so cache.

Ramon> Having said that, I am not out of the woods yet. The new
Ramon> error message says:

Ramon> nclaims: FAILED: OCIInitialize() nclaims: FAILED:
Ramon> init_handles() nclaims: There was an error on 'OCILogon' [Thu
Ramon> Jul 3 03:39:02 2003] [error] [client x.x.x.x] Premature end of
Ramon> script headers: /home/ramon/public_html/cgi-bin/claimsof.cgi

Ramon> (the same programs runs flawlessly from the Unix shell).

Ramon> Now it looks like the OCI .so library is being found at link
Ramon> time, but not at execute time??

When running your OCI cgi program from the unix shell are you using
the same user that apache is running as? e.g. nobody?

It could be that when you are testing it, you have a properly defined
oracle environment (ORACLE_HOME, ORACLE_SID etc), but not when the cgi
script is running under the user who runs apache or the user who is
running apache does not have access to directories needed etc.

Tim

--
Tim Cross
The e-mail address on this message is FALSE (obviously!). My real e-mail is
to a company in Australia called rapttech and my login is tcross - if you
really need to send mail, you should be able to work it out!
 
Reply With Quote
 
 
 
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Dynamically Change SSID fernandez.dan@gmail.com Wireless Internet 1 06-20-2008 01:04 AM
Dynamically assign IP based on MAC DEBEDb Linux Networking 6 02-01-2007 12:42 AM
changing tcp window size dynamically for FTP on linux anuragmenon@gmail.com Linux Networking 1 09-06-2006 01:20 AM
How do I change IP address dynamically? linuxlover992000@yahoo.com Linux Networking 17 06-21-2006 08:08 PM
Dynamically detect network environment wim delvaux Linux Networking 1 11-27-2003 12:18 AM



1 2 3 4 5 6 7 8 9 10 11