两个解析cgi参数的脚本

1, c语言的脚本,推荐.

介绍

This page presents a little program that will help you processing form data in a CGI shell script. If you’re unfamiliar with Perl and don’t want to write a bulky C program just for a small CGI job, shell script CGI programming may be an option. You receive the form values straight into your shell environment (the names prefixed with “FORM_”), where you can then access them just like other shell variables. (在参数名前加上”FORM_”的前缀)

安装

在linux下可以用: gcc -o proccgi proccgi.c,这样就生成了一个proccgi的文件。

用法

在Cgi脚本的开头加上一句:

eval "`proccgi $*`"     #proccgi最好用全路径

下载

Once again, here’s a link to download proccgi.c.

原文: http://www.fpx.de/fp/Software/ProcCGI.html

2, shell语言的脚本,在没有C语言的环境下

用法

eval `proccgi.sh $*`  #在不可执行的情况,用`sh  proccgi.sh $*` ,proccgi.sh 用全路径

下载

Don’t forget to download the code, proccgi.sh.

原文:http://www.fpx.de/fp/Software/ProcCGIsh.html

 

Example

This is a very simple example of an automatic software-by-email program. You can fill in your email address and a file name which is then automatically mailed to you. Do not, I repeat, do not install this piece of code. It would be a major security leak.

The Form

<form action="http://our-server/cgi-stuff/mailer" method="post">
<dl>
  <dt> Your Email <dd> <input name="email" size="50">
  <dt> Filename   <dd> <input name="file"  size="50">
</dl>
<input type="submit" value="Submit">
</form>

The Script

#!/bin/sh
eval `proccgi.sh $*`
mail $FORM_email < $FORM_file
cat - << \END
echo Content-type: text/plain
echo
echo done.
END
2 回复

评论已关闭。