Chinaunix首页 | 论坛 | 博客
  • 博客访问: 3287746
  • 博文数量: 266
  • 博客积分: 3081
  • 博客等级: 中校
  • 技术积分: 2640
  • 用 户 组: 普通用户
  • 注册时间: 2005-07-04 10:35
个人简介

没什么好介绍的!穷屌丝一个~

文章分类

全部博文(266)

文章存档

2021年(3)

2020年(1)

2019年(2)

2016年(5)

2015年(1)

2014年(1)

2011年(9)

2010年(16)

2009年(31)

2008年(58)

2007年(111)

2006年(2)

2005年(26)

我的朋友

分类:

2007-06-01 22:21:15

1. BusyBox httpd CGI scripts

The http daemon expects that CGI script is in subdirectory cgi-bin under main web directory set by options -h (default /www and CGI in /www/cgi-bin). CGI script must have permision for execute (min mode 700).

1.1. CGI

Standard set of Comon Gateway Interface environment variable are :

CONTENT_TYPE=application/x-www-form-urlencoded
GATEWAY_INTERFACE=CGI/1.1
REMOTE_ADDR=192.168.1.180
QUERY_STRING=Zbr=1234567&SrceMB=&ime=jhkjhlkh+klhlkjhlk+%A9%D0%C6%AE%C6%AE&prezime=&sektor=OP
REMOTE_PORT=2292
CONTENT_LENGTH=128
REQUEST_URI=/cgi-bin/test
SERVER_SOFTWARE=busybox httpd/1.35 6-Oct-2004
PATH=/bin:/sbin:/usr/bin:/usr/sbin
HTTP_REFERER=
SERVER_PROTOCOL=HTTP/1.0
PATH_INFO=
REQUEST_METHOD=POST
PWD=/www/cgi-bin
SERVER_PORT=80
SCRIPT_NAME=/cgi-bin/test
REMOTE_USER=[http basic auth username]

/cgi-bin/test

#!/bin/sh
echo "Content-type: text/html"
echo ""
echo "Sample CGI Output"
echo ""
echo "
"
env
echo "
" echo " "

Environment variables are set up and the script is invoked with pipes for stdin/stdout.

1.2. HTML Forms

If a post is being done the script is fed the POST data in addition to setting the QUERY_STRING variable (for GETs or POSTs).

Prefered way to do forms in CGI is POST.

1.2.1. POST

Example how to use POST in form.

/www/form-post.html



CGI Test



Text field

Radio button

1

2

3

Some text

 

 

 

/www/cgi-bin/test-post

#!/bin/sh
echo "Content-type: text/html"
echo ""
echo "Sample CGI Output"
echo ""
echo "
"
echo "Environment variables"
echo ""
env
echo ""
echo "========================================================="
echo ""
echo "Form variables :"
echo ""
read QUERY_STRING
eval $(echo "$QUERY_STRING"|awk -F'&' '{for(i=1;i<=NF;i++){print $i}}')
tmp=`httpd -d $Text_Field`
echo "Text_Field=$tmp"
tmp=`httpd -d $Radio_Button`
echo "Radio_Button=$tmp"
tmp=`httpd -d $Text_Area`
echo "Text_Area=$tmp"
echo "
" echo ""

1.2.2. GET

Text area fields (and any other field that may contain \n are very hard to menage).

Example how to use GET in form.

/www/form-get.html



CGI Test



Text field

Radio button

1

2

3

 

 

 

/www/cgi-bin/test-get

#!/bin/sh
echo "Content-type: text/html"
echo ""
echo "Sample CGI Output"
echo ""
echo "
"
echo "Environment variables"
echo ""
env
echo ""
echo "========================================================="
echo ""
echo "Form variables :"
echo ""
eval $(echo "$QUERY_STRING"|awk -F'&' '{for(i=1;i<=NF;i++){print $i}}')
tmp=`httpd -d $Text_Field`
echo "Text_Field=$tmp"
tmp=`httpd -d $Radio_Button`
echo "Radio_Button=$tmp"
echo "
" echo ""

OpenWrtDocs/httpd CGI scripts (dernière édition le 2006-09-18 21:55:07 par phat_bastard)

Almost all of these pages are editable, create an account and click the edit (Edit) button at the top of the page.

阅读(1966692) | 评论(6) | 转发(0) |
给主人留下些什么吧!~~

chinaunix网友2010-04-30 09:46:42

可以执行 CGI的。

chinaunix网友2010-04-30 09:46:42

可以执行 CGI的。

chinaunix网友2009-12-26 11:53:01

Halfway through the year SPIN tipped their hand by offering the 20 Greatest Albums Of 2009 ... So Far. If you remember, the list wasn't in any specific order. Their 40 Best [url=http://www.ugg-boots-store.net]ugg boots store[/url] Albums Of 2009 are, and it's interesting to see all the titles that popped up after the last one was published. As well as the albums that missed the cut after [url=http://www.watchesxm.com]Cheap watches[/url] they were spun a bit more: Peter Bjorn And John, Blk J

chinaunix网友2009-12-26 11:53:01

Halfway through the year SPIN tipped their hand by offering the 20 Greatest Albums Of 2009 ... So Far. If you remember, the list wasn't in any specific order. Their 40 Best [url=http://www.ugg-boots-store.net]ugg boots store[/url] Albums Of 2009 are, and it's interesting to see all the titles that popped up after the last one was published. As well as the albums that missed the cut after [url=http://www.watchesxm.com]Cheap watches[/url] they were spun a bit more: Peter Bjorn And John, Blk J

chinaunix网友2008-11-12 10:17:46

还不能执行CGI 啊。只会把CGI 的源码显示到 IE上。感觉是httpd 的设置还有缺失。哪位高手有何高见?