Perl脚本不是在HTML表单执行 [英] Perl script is not executing in HTML form

查看:261
本文介绍了Perl脚本不是在HTML表单执行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在命名为铬(/home/chankey/Desktop/Chrome/guestbook.htm),其内容如下 guestbook.htm 文件p>

I have a guestbook.htm file in the directory named as Chrome (/home/chankey/Desktop/Chrome/guestbook.htm) whose content is given below

<html>
<head>
<title>Guestbook</title>
</head>
<body>

<form action="/home/chankey/Desktop/Chrome/guestbook.pl" method="get">
<table>
<tr><td>Name</td><td><input name="name" type="text" value=""></td></tr>
<tr><td>E-Mail</td><td><input name="email" type="text" value=""></td></tr>
<tr><td>Location</td><td><input name="loc" type="text" value=""></td></tr>
<tr><td>Comments</td><td>
<TEXTAREA name="comments" rows="10" cols="32"></TEXTAREA></td></tr>
</table><br><br>
<input type="submit" value="Add Entry">
</form>

</body>
</html>

在同一个chrome目录我有一个文件guestbook.pl,其内容是

In the same Chrome directory I have one file "guestbook.pl" whose content is

#!/usr/bin/perl

my $query_string = "";
#Get the input
if ($ENV{REQUEST_METHOD} eq 'POST') {
read(STDIN, $query_string, $ENV{CONTENT_LENGTH});
} else {
$query_string = $ENV{QUERY_STRING};
}
##### We will remove this
print "Content-Type: text/html\n\n";
print "Query String is \n<br> $query_string";
##### We will remove this

当我执行出现了一个形式guestbook.htm文件,当我填写资料,并点击添加条目按钮,一个新页面打开会出现完整的脚本在哪里。

When I am executing the guestbook.htm file there appears a form, when I fill the data and click on "Add Entry" button a new page opens where the complete script appears.

即。脚本guestbook.pl没有执行。我想知道这背后的原因是什么?为什么脚本不执行? (我已经给执行权限在此文件)。

i.e. the script "guestbook.pl" is not executing. May I know the reason behind this? Why the script is not executing? (I have already given executing permission to this file).

在httpd.conf文件我已经加入

In the httpd.conf file I have added

AddHandler cgi-script cgi pl
<Directory /home/chankey/Desktop/Chrome/>
    Options +ExecCGI
</Directory>

仍是不执行。让我知道原因。

Still it is not executing. Let me know the reason.

推荐答案

当您访问本地文件(在文件:// 在浏览器中键入URL)它不是从网络服务器上运行,所以

When you access a file locally (over the file:// type URL in your browser), it's not running from a web server, so:


  • 没有CGI环境

  • 的httpd.conf / 的.htaccess 文件没有任何效果

  • There is no CGI environment
  • The httpd.conf/.htaccess files have no effect

有几个方法来处理这​​样的:

A few ways to deal with this:


  • 创建的public_html 在您的家命名的文件夹。您的Web服务器可能有一个设置地图的http://本地主机/〜chankey / /家庭/ chankey /的public_html 。 (MacOSX上,在preferred名为网​​站,相反,我相信。)在一个SELinux的系统,你必须专门授予权限的Apache使用此方法。

  • 对于使用标准的 CGI 包Perl脚本的具体情况,也可以手动从终端shell中运行它们,它们的输出重定向到一个临时文件(如: &GT; /tmp/output.html ),然后您就可以访问

  • 迁移的开发工作区到Web服务器自身的目录结构,一般的/ var / www / html等/ ...

  • Create a folder named public_html in your home. Your web server likely has a setting to map http://localhost/~chankey/ to /home/chankey/public_html. (On MacOSX, the preferred name is Sites, instead, I believe.) On an SELinux system, you'll have to specifically grant permission for Apache to use this method.
  • For the specific case of Perl scripts using the standard CGI package, you can also run them manually from a terminal shell, and redirect their output to a temporary file (e.g. >/tmp/output.html), which you can then access
  • Migrate your development workspace into your web server's own directory structure, typically /var/www/html/

PS /无关系:我强烈建议,如果你打算把这个在互联网上,你应该使用CGI;使用严格的;!并启用污点模式#的/ usr / bin中/ perl的-WT ...

PS / unrelated: I strongly recommend that, if you plan to put this on the Internet, you should probably use CGI; use strict; and have the tainting mode enabled #!/usr/bin/perl -WT

这篇关于Perl脚本不是在HTML表单执行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆