use*_*000 5 bash shell post cgi
我正在使用bash编写的CGI脚本编写Web应用程序。
对于GET请求,请求参数可在名为的变量中使用$QUERY_STRING。但是,我无法确定类似的值将存储在哪里以供POST请求。
我正在使用以下脚本:
#!"c:/msys64/usr/bin/bash.exe"
# On *nix, replace above with #!/bin/bash
echo -en "Status: 200 OK\r\n"
echo -en "Content-type: text/plain\r\n\r\n"
declare -x
declare -a
Run Code Online (Sandbox Code Playgroud)
这就是我得到的:
$ curl -so - --data "abc=ZZZZZZ&d=PPPPPPPP" http://localhost/cgi-bin/test.sh | grep ZZZZZZ
$ curl -so - "http://localhost/cgi-bin/test.sh?abc=ZZZZZZ&d=PPPPPPPP" | grep ZZZZZZ
declare -x QUERY_STRING="abc=ZZZZZZ&d=PPPPPPPP"
declare -x REQUEST_URI="/cgi-bin/test.sh?abc=ZZZZZZ&d=PPPPPPPP"
Run Code Online (Sandbox Code Playgroud)
如何检索通过POST请求发送的值?
(如果有关系,我正在使用Apache 2.4)。
使用POST方法时。POST值将作为CGI程序的输入。所以在bash中使用
read POST_STRING
Run Code Online (Sandbox Code Playgroud)
然后POST_STRING包含POST值,其格式与QUERY_STRING保留GET请求的值相同。
| 归档时间: |
|
| 查看次数: |
7682 次 |
| 最近记录: |