Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Apache reads scripts as html, not cgi

by Anonymous Monk
on Jul 04, 2001 at 02:51 UTC ( [id://93715]=perlquestion: print w/replies, xml ) Need Help??

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

I just got my apache web server up for Windows 98, and I added the Script Alias, but whenever I run my script, it runs as html...apache isn't executing it as a .cgi Anyone who uses apache, help would be very appreciated, thanks!

Replies are listed 'Best First'.
Re: Apache reads scripts as html, not cgi
by blakem (Monsignor) on Jul 04, 2001 at 03:16 UTC
    Without seeing your configuration, its hard to determine exactly what is wrong... However, it sounds like you might need to add:

    AddHandler cgi-script .cgi
    to your configuration file.

    -Blake

Re: Apache reads scripts as html, not cgi
by Maestro_007 (Hermit) on Jul 04, 2001 at 09:59 UTC
    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:

      #!C:\perl\bin\perl5.6.1.exe

    • 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!

    MM

Re: Apache reads scripts as html, not cgi
by Tuna (Friar) on Jul 04, 2001 at 05:28 UTC
    I know you said that you added your alias, but, on my Linux box, there is a file, "test-cgi", that one can use to see if Apache is properly configured to exec cgi scripts (assuming perms are in order). Do you have anything like that on your machine?
Re: Apache reads scripts as html, not cgi
by RatArsed (Monk) on Jul 05, 2001 at 16:42 UTC
    Any particular version of Apache?

    Have you got an AddHandler line?

    does you #! point at the installation of perl?

    --
    RatArsed

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://93715]
Approved by root
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (5)
As of 2024-06-24 06:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.