Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW

Re: Apache reads scripts as html, not cgi

by Maestro_007 (Hermit)
on Jul 04, 2001 at 09:59 UTC ( #93795=note: print w/replies, xml ) Need Help??

in reply to Apache reads scripts as html, not cgi

First of all, you need to post some code for anyone to get an idea of what the problem may be.

Second, there are several things you need to look for (oversimplified, but they should work):

  • A shebang line at the top of the .cgi script, which on Win32 versions, looks something like this:


  • In most cases, Apache will interpret /(forward slash, UNIX-style) symbols as \(backslash, Win32-style) for Win32, but I've found that this is not the case for the shebang line.
  • Make sure you are sending the proper <FORM ACTION="script.cgi" METHOD=""> (assuming you're passing from another HTML document) through to the script in the request header. The METHOD needs to be a GET or POST request in order to work. Nearly any web page will have an example of a FORM tag. Heck, hit View Source now and do a search. I'll bet it's there somewhere.
  • The AddHandler Directive recommended by blakem is also a good one for testing, but I've heard arguments against keeping this handler in place permanently. It came up in O'Reilly's CGI Programming With Perl, 2nd Ed., pp. 14-15. This directive allows any .cgi script which is accessible from the server to be run as a script. If a Bad Guy sees that scripts are run that are not in the /cgi-bin/ directory, he may try to look for a file called "script.bak", or "script.cgi~", which would be left behind by lots of text editors. He could then view the source code and exploit it. Maybe it's not a very likely scenario, but it's something to think about if you use CodeWright, Visual Studio, or even emacs! I would leave this handler in place just long enough to test the scripts.

If none of these helps at all, you'll need to post some code and snippets of your httpd.conf files.

Good luck!


Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://93795]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (5)
As of 2023-02-05 21:30 GMT
Find Nodes?
    Voting Booth?
    I prefer not to run the latest version of Perl because:

    Results (33 votes). Check out past polls.