为了步骤从HTML表单数据传递给Perl脚本 [英] Steps in order to pass data from HTML form to Perl script

查看:451
本文介绍了为了步骤从HTML表单数据传递给Perl脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个简单的HTML,它包含以下表格:

I have created a simple HTML, which contains the form below:

<form action="WEB-INF/cgi/run.pl" method="post">
      <table border="0" cellspacing="0"> 

      <tbody>
      <tr><th align="center" bgcolor="F7F5F2"> <p class="normal">Submission Form</p> </th></tr>

      <tr><td align="center" bgcolor="F7F5F2"> <p class="normal">Insert your text below:</p> </td></tr>
      <tr><td><textarea wrap="virtual" name="seq_data" rows="15" cols="80"></textarea></td></tr>  
    </tbody></table>
    or upload a file :   <input type="file" name="file" size="29" border="0"><br><br>
    <input class="normalc" value="Submit Query" type="submit">
    <input class="normalc" value="Clear Form" type="reset"><p></p>
</form>

我需要从形式输入数据传递到一个Perl脚本(run.pl)。

I need to pass the data from the form as input to a perl script (run.pl).

虽然搜索互联网我已阅读了:
1)我需要通过的Apache Tomcat来测试我的网站。我已经安装了Apache的版本7.0和周围这个servlet删除XML注释修改了Tomcat的7.0 / conf目录/ web.xml文件:

While searching the internet I have read that: 1) I need to test my website through apache tomcat. I have installed apache version 7.0 and modified the Tomcat 7.0/conf/web.xml file by removing the XML comments from around this servlet:

<servlet>
    <servlet-name>default</servlet-name>
    <servlet-class>org.apache.catalina.servlets.DefaultServlet</servlet-class>
    <init-param>
        <param-name>debug</param-name>
        <param-value>0</param-value>
    </init-param>
    <init-param>
        <param-name>listings</param-name>
        <param-value>false</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
</servlet>

我也创建中,我把我的perl脚本目录WEB-INF / cgi的。

I have also created the directory "WEB-INF/cgi" in which I placed my perl script.

2)我需要修改我的Perl脚本,但我不能发现什么,我应该为了从HTML表单中的数据传递给我的脚本添加。

2) I need to modify my Perl script, but I can't find out what I should add in order to pass the data from the html form to my script.

我不知道是否有比修改Tomcat和Perl脚本等其他任何必要的步骤。
我看了很多相关的话题,但我仍然无法找到一个一步一步的指导。请帮助。

I don't know if there are any other necessary steps other than modifying Tomcat and Perl script. I have read many relevant topics, but I still can't find a step by step guide. Please help.

推荐答案

当Web服务器接收到其通常响应与该资源的内容的HTTP请求。但是,如果该URL指定通用网关接口(CGI)资源,它将运行它,并返回输出方案来代替。

When a web server receives an HTTP request it generally responds with the contents of the resource. However if the URL specifies a Common Gateway Interface (CGI) resource it will run it and return the output of the program instead.

该服务器的配置指定CGI和非CGI资源之间的区别,这可以被或者基于文件扩展名 - 的CGI 特等等 - 或者文件所在的服务器的目录结构。

The server's configuration specifies the distinction between CGI and non-CGI resources, and this can be be based either on the file extension - .cgi, .pl etc. - or on where the file is in the server's directory structure.

服务器传递在HTTP请求到通过其STDIN CGI程序也过程的环境变量的信息。通常,对于一个把参数 POST 请求将出现在STDIN而为 GET 的请求被插入到环境变量。

The server passes on the information in the HTTP request to the CGI program through its STDIN and also the environment variables of the process. In general the parameters for a PUT or POST request will appear in STDIN while those for a GET request are inserted into the environment variables.

该计划的工作是建立基于这些参数所需要的反应,并将​​其打印到标准输出。它也可以利用数据库​​信息和其它系统信息。这个输出将被服务器用作HTTP响应的内容。

The program's job is to build the required response based on these parameters and print them to STDOUT. It may also make use of database information and other system information. This output will be used by the server as the content of the HTTP response.

您应该看看 的Perl CGI模块 它包装在方便的子程序此接口。

You should look at the Perl CGI module which wraps this interface in convenient subroutines.

这篇关于为了步骤从HTML表单数据传递给Perl脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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