Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.tools -> Re: Where does CGI script get HTTP_USER_AGENT and PATH values from?
Hi Terri,
you performed case2, run the script out of command line.
If you try to perform case1: script resides on apache's directory
cgi-bin (full path eg /usr/local/apache/cgi-bin, check your specific
installation, full path may vary!)
example of an URL on my machine:
http://dog.workgroup:8080/cgi-bin/hash_cgi.pl
you see the complete listing of apache's environment variables:
<snip>
HTTP_USER_AGENT: Mozilla/4.76 [en] (X11; U; Linux 2.4.2-2 i686)
</snip>
Gives you info about my webbrowser (client, OS, and cpu-type, more info
than I want any user to see...).
You have to copy the script in apache's directory cgi-bin to see this
output.
To answer you original question more specifically: The variable
HTTP_USER_AGENT is set by apache, in the file httpd.conf.
This is the main configuration file for apache.
You find the file in subdir /conf. Full path (remember, may vary as said
above) /usr/local/apache/conf
Snippet of a httpd.conf, around line 865, depends on apache-version
(here: apache 1.3.22):
<snip>
# Customize behaviour based on the browser
#
<IfModule mod_setenvif.c>
...
#NOTE: THIS CATCHES MY CLIENT (=WEBBBROWSER)
BrowserMatch "Mozilla/2" nokeepalive
...
#NOTE THE JAVA ENTRY ON NEXT LINE!!!! # I assume the two following lines are responsible for # your output:
BrowserMatch "Java/1\.0" force-response-1.0 BrowserMatch "JDK/1\.0" force-response-1.0
</IfModule>
</snip>
In your case, your Java application behaves like my webbrowser (means:
both play the client role).
You can set/edit your own "Browser match string". Take a look at:
http://httpd.apache.org/docs/mod/mod_setenvif.html#BrowserMatch
for further explanations and three examples.
In summary: The file httpd.conf has the relavant info about the client.
If you have installed the necessary
software (JDK/JRE), path is set correct... (means you are sure that
there no other basic problems)
try to edit the httpd.conf, so webserver apache is informed about your
software version.
Pleae note: If you are working with https, please search for http*.conf
(maybe filename is https.conf),
but I'm not sure about the exact name.
Hope this helps, feel free to send reply, further questions... Manuela Mueller
"Terri I." wrote:
>
> The PERL CGI script that I am connecting to does run the command you
> suggested - it displays values of all environment variables, as well
> as output of whoami and id commands. What I'm trying to figure out is
> where some of those settings (namely the HTTP_USER_AGENT) are being
> set (i.e., which web server configuration file is setting it).
>
> FYI, I am running Oracle 8.1.7 and Apache on SunOS 5.6, on a SunSPARC.
>
> Manuela Mueller <520040906697-0001_at_t-online.de> wrote in message news:<3C12A9D3.169F3BA6_at_t-online.de>...
> > "Terri I." wrote:
> > >
> > > I've got an Oracle application that is launching some Java
> > > code to connect via https to a CGI script. That CGI script writes a
> > > file with all environment variables. The HTTP_USER_AGENT value is
> > > "Java1.2.1", although I've installed the 1.3.1 version of the JDK/JRE
> > > on the server. I cannot figure out what configuration files (Oracle?
> > > Apache?) are making the settings that the CGI script then displays.
> > > Can someone tell me where the web server settings are defined that
> > > would cause the HTTP_USER_AGENT field to be set to Java1.2.1??
> > > Because of this, my application will not work properly because it
> > > requires JDK 1.3. I set the path and classpath for the 'Oracle' user,
> > > but maybe browser https requests are treated as some other user such
> > > that the appropriate paths are not being referenced.
> >
> >
> > Hello Terri,
> > don't know your platform, web server software, if you have perl
> > installed.
> > If you have it installed, th following simple script might answer your
> > question
> >
> > #!/usr/bin/perl
> > # case 1: Program runs via apache, webbrowser is client: show alls
> > variables for the hash %ENV
> > # case 2: Program runs simply via command line, shows all settings for
> > the user
> > # (like SET command)
> > print "Content-type: text/html", "\n\n";
> >
> > print <<end;
> > <html>
> > <head>
> > <title>ENV</title>
> > </head>
> > <body>
> > <h1>Environment variables of Apache-Servers</h1>
> > <ul>
> > end
> >
> > foreach $key (sort keys(%ENV)) {
> > print "<li>$key: $ENV{$key}</li>\n";
> > }
> >
> > print <<end_all;
> > </ul>
> > </body>
> > </html>
> > end_all
> >
> > exit(0);
> >
> > Feel free to drop me a line if you have questions baout the script.
> > Manuela Mueller
> > PS: I assume it is the web server.
Received on Mon Dec 10 2001 - 13:36:15 CST