Solved

Apache CGI Config

Posted on 1997-07-17
8
589 Views
Last Modified: 2013-12-20
I am running an Apache web server on Slakware Linux 2.0.29.  I think my config files are correct, but I can't execute my CGI scripts.  I'll include the following: HTML,httpd.conf, asm.conf, access.conf.  for the HTML, I've tried both of the following:
<!--#exec cgi="logger.cgi"-->
and
<!--#exec cmd="logger.cgi"-->
neither worked.
I'm pretty sure I have all the mods loaded that I need.
In my config files I have all of the following lines:
==============================================
ScriptAlias   /cgi-bin/   /<path>/cgi-bin/

<Directory /<path>/cgi-bin/>
Options +Includes
</Directory>

What could be wrong?

--Tom Langan
--tlangan@geocities.com
0
Comment
Question by:langan
  • 4
  • 4
8 Comments
 
LVL 2

Expert Comment

by:Philippe
ID: 1829144

Iangan,

When you do an exec, the path is relative to the current document.

Supposing logger.cgi is in your cig-bin directory (as this is the only one in the script alias), what you want to say is

<!--#exec cgi="/cgi-bin/logger.cgi"-->

If the logger.cgi is not in the cgi-bin directory, then you have to specify its path with ScriptAlias or ExecCgi

Hope this solves your problem.


 cheers,

   Philippe


0
 

Author Comment

by:langan
ID: 1829145
My apologies.  the actual line IS in fact:

<!-- #exec cmd="/cgi-bin/logger.cgi"  -->
although I have also tried:
<!--  #exec cgi="/cgi-bin/logger.cgi"  -->

I think the HTML is okay.  I also tried to do a "#echo var=" line, but that didn't work either.

-Again, I compiled my server with the mod_cgi and mod_include files, and I have /cgi-bin/ ScriptAlias'ed and I have
"Options +Include" in that directory.  Why doesn't SSI work at all?
0
 
LVL 2

Expert Comment

by:Philippe
ID: 1829146

> My apologies the actual line IS in fact:  
Hmmm.....

Do you get any errors in the error log?

Do cgi-scripts work? Eg: http://your.server/cgi-bin/logger.cgi

Which version of apache do you have?

What is the '+' in front of Include? If my memory serves me right, this should read "Options Include"

 Phil

0
 

Author Comment

by:langan
ID: 1829147
Okay.. Some more useful info:
1 - I have the HTML file set to parsed-html w/AddHandler and AddType, it's called "/Active/cgi.shtml" w/the HTML above.  Is that correct?

2 - In the Apache documentation it says that the correct syntax is "Options [+/-]option"  

3 - Some CGI files work when I run them directly others don't.  I have a simple counter which works when I resolve "/cgi-bin/count.pl" .. but "/cgi-bin/logger.cgi" , which writes browser info works from a prompt, but not when I run it from a browser.  And yet another, which writes the same "logger" info to the browser window gets a "Internal Server Error" .. the error log says "unexpected end of script" , yet the script runs perfectly from a prompt?

4 - The actual "<!-- #exec ....." shows up in the "View..source code" window

5 - I'm running Apache 1.2.0 on Linux 2.0.29 on an i486-DX2 66 machine with 16mb RAM

Thanx,

-Tom
0
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
LVL 2

Expert Comment

by:Philippe
ID: 1829148

1 - I have the HTML file set to parsed-html w/AddHandler and AddType, it's called "/Active/cgi.shtml" w/the HTML above. Is that correct?
 
Not sure.. From the docs you should have something like

AddType text/html .shtml
AddHandler server-parsed .shtml

and then you should call your file myfile.shtml



2 - In the Apache documentation it says that the correct syntax is "Options [+/-]option"

Sorry, I still had 1.0 docs

3-  Some CGI files work when I run them directly others don't.

First of all, there seems to be a bug in your logger.cgi Could be something wrong in the headers it generates. Can you show me the output of the that script when you run it from the prompt (and of the one that generates the Internal error). Does exec work with the correct scripts like count.pl?

What does the error log say?


 Ph

0
 

Author Comment

by:langan
ID: 1829149
Logger.cgi:
Purpose:  to write user info to a file.
Shell:  Works perfectly, writes output to a file (minus the server variables)
#exec:  Doesn't execute, leaves '<!-- #exec..' in the source code instead of replacing it with the SSI code
/cgi-bin/logger.cgi:  blank screen, doesn't write to file

i_spy.cgi:
Purpose:  to write user info to browser window
Shell:  writes correct HTML w/o server variables to standard output
#exec:  doesn't execute, leaves '<!-- #exec..' in source code instead of replacing
/cgi-bin/i_spy.cgi:  internal error: premature end of script headers

count.pl:
Shell:  writes to 'count' file (+1 every time) and writes number to standard output
#exec:  Doesn't execute, leaves "<!-- #exec.." in source code instead of replacing with SSI
/cgi-bin/count.pl:  writes correct number to browser screen

other SSI:
'<!-- #echo var=..' tag does not execute either.

-I have tried with and w/o the '+', and it doesn't seem to make a difference

-Tom
0
 
LVL 2

Accepted Solution

by:
Philippe earned 150 total points
ID: 1829150

tom,

I just installed apache a tested your setup:

there is a simple error (hope it is not a typo again!):
there should be no space between the !-- and the # in your exec directive eg:

<!--#exec cgi="/cgi-bin/test-cgi" -->

rather than

<!-- #exec cgi="/cgi-bin/test-cgi" -->

Use test-cgi as example to be sure that the problem does not come from your cgi script

Then I didn't understand what you mean by:

1 - I have the HTML file set to parsed-html w/AddHandler and AddType, it's called "/Active/cgi.shtml" w/the HTML above.

What you need to have is just

AddType text/html .shtml
AddHandler server-parsed .shtml

and then you nead to have the "include" option for the directory that contains the shtml file, not the cgi files:

<Directory your_directory_with_the_shtml_files>
Includes
</Directory>

(I have it in the htdocs, so I just added Includes to the section about the htdocs directory)

For the cgi-bin directory you just need the standard thing:

<Directory your_path/cgi-bin>
AllowOverride None
Options None
</Directory>


This should solve your problem. Please accept this as answer. I'll be happy to give more info if you add more comments after that.

 Philippe

0
 

Author Comment

by:langan
ID: 1829151
Thanks for your help, Philippe.. it works great!  :-)


0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
exchange 2007, scripts 15 73
Problem to ToolkitScriptManager 2 51
Run command in each subfolder using batch file 7 50
Stupid git question 2 62
Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL (http://www.experts-exchange.com/articles/201/Handling-Date-and-Time-in-PHP-and-MySQL.html) several years ago, it seemed like now was a good time to updat…
JavaScript has plenty of pieces of code people often just copy/paste from somewhere but never quite fully understand. Self-Executing functions are just one good example that I'll try to demystify here.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now