开发者

cgi script is not executing

I have a perl.cgi file which has the content:

#!/usr/bin/perl 
print "Content-type: text/html\n\n";
print "<h1>Hello World</h1>\n";

I made it executable. (chmod a+x perl.cg开发者_Go百科i)

Then I created a new file perl.htm in the same directory. Which has the following data:

Content-type: text/html
<p><a href="perl.cgi">RUN perl.cgi</a></p>

When I run the perl.htm in my browser then I get the output as:

Content-type: text/html
RUN perl.cgi

When I click on RUN perl.cgi another page opens and there the output is:

#!/usr/bin/perl 
print "Content-type: text/html\n\n";
print "<h1>Hello World</h1>\n";

i.e. the perl.cgi is not executing. Only the file contents are being shown.

EDIT: From the answers and comments I came to know that I will have to configure my web server (apache) to run cgi scripts. How can I do that? Let me know.


Sounds like Apache is not configured to run *.cgi files:

AddHandler cgi-script cgi pl
<Directory /path/to/cgi/files>
    Options +ExecCGI
</Directory>


Make sure you are loading the CGI module in the httpd.conf file:

LoadModule cgi_module modules/mod_cgi.so or LoadModule cgi_module modules/mod_cgid.so depending on which version of Apache you are running.

You can also read about additional solutions for Dynamic Content with CGI.


Problem has been solved. I was not using httpd service at all, was opening from file:// URL.

Perl script is not executing in HTML form


You need to setup your web server so that it executes *.cgi files (or, more normally, all the files in a particular directory) rather than just delivering them to the browser as it does .html files.

How this is done depends on your server.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜