Apache CGI Config

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
langanAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

PhilippeCommented:

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
langanAuthor Commented:
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
PhilippeCommented:

> 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
Cloud Class® Course: Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

langanAuthor Commented:
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
PhilippeCommented:

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
langanAuthor Commented:
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
PhilippeCommented:

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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
langanAuthor Commented:
Thanks for your help, Philippe.. it works great!  :-)


0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Scripting Languages

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.