另一个CGI/shell问题(在脚本中接收FORM数据)

dphi5xsq  于 2023-04-07  发布在  Shell
关注(0)|答案(1)|浏览(147)

简单地说:在离开网络技术很长一段时间后,我准备退休时再次尝试它。因此,这只是我在本地机器上尝试的沙箱实验。我使用的是Aprelium的Abyss Web服务器的X1版本,多年来我已经成功地用于各种目的。
我有一个小sqlite数据库,我已经建立了只包含一个表,吉他库存。我希望有一个网页形式,要求使和模型,并通过这些值的shell脚本,并返回结果在网页上的一个框架。
我可以成功地运行一个“select * from”sqlite3查询,但是我在如何接收表单值方面遇到了困难。
make=Fender
model=Telecaster
sqlite3 -list guitardb 'select * from inventory where make = "${make}" and model = "${model}";'
但我似乎无法捕获FORM数据。我创建了一个简单的CGI脚本来显示处理FORM时返回的环境变量,但显示中没有QUERY_CONTENT或RESPONSE_QUERY或任何数据值。我可以看到POST或GET方法,但两者都没有给我数据。
我知道Abyss不是最知名的Web服务器,但我已经在办公环境中使用luxcal运行过它,并具有文件上传/下载功能,我甚至制作了一个phpBB 3论坛模型,所以我知道这是可能的。
(Why你可能会问,我不使用php?仅仅是因为我当时不想学习一门新的编程语言。正如我所说,这是一个概念证明,我想我已经很接近了。任何帮助都将不胜感激。
这是从调用我的脚本显示环境变量的响应。编辑删除用户名。(抱歉的长度)。REQUEST_METHOD(GET在这种情况下)显示,但不是数据:

XPC_SERVICE_NAME=0
PATH=/usr/bin:/bin:/usr/sbin:/sbin
XPC_FLAGS=0x0
SERVER_SOFTWARE=Abyss/2.16.4-X1-macOS AbyssLib/2.16.4
SERVER_PROTOCOL=HTTP/1.1
HTTPS=off
IS_SUBREQ=false
HTTP2=off
COOKIE=phpbb3_qtei6_k=; PHPSESSID=d7mvb47vlrd43160290ugec0n9; PHPSESSIDmycal=d7mvb47vlrd43160290ugec0n9mycal; phpbb3_qtei6_u=2; phpbb3_qtei6_sid=3961a5f7ff7cf89e8b34ab94a5559a7d
SERVER_PORT=80
SERVER_NAME=localhost
SERVER_ADDR=::1
LOCAL_ADDR=::1
REMOTE_ADDR=::1
REMOTE_PORT=62529
REQUEST_URI=/cgi-bin/envvars.sh?
GATEWAY_INTERFACE=CGI/1.1
DOCUMENT_ROOT=/Users/user/Abyss Web Server/htdocs
APPL_MD_PATH=/
APPL_PHYSICAL_PATH=/Users/user/Abyss Web Server/htdocs
URL=/cgi-bin/envvars.sh
SCRIPT_URI=http://localhost/cgi-bin/envvars.sh?
SCRIPT_URL=/cgi-bin/envvars.sh?
SCRIPT_NAME=/cgi-bin/envvars.sh
SCRIPT_FILENAME=/Users/user/Abyss Web Server/htdocs/cgi-bin/envvars.sh
REQUEST_FILENAME=/Users/user/Abyss Web Server/htdocs/cgi-bin/envvars.sh
REQUEST_METHOD=GET
CONTENT_LENGTH=0
HTTP_HOST=localhost
HTTP_CONNECTION=keep-alive
HTTP_SEC_CH_UA="Brave";v="111", "Not(A:Brand";v="8", "Chromium";v="111"
HTTP_SEC_CH_UA_MOBILE=?0
HTTP_SEC_CH_UA_PLATFORM="macOS"
HTTP_UPGRADE_INSECURE_REQUESTS=1
HTTP_USER_AGENT=Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Safari/537.36
HTTP_ACCEPT=text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8
HTTP_SEC_GPC=1
HTTP_ACCEPT_LANGUAGE=en-US,en
HTTP_SEC_FETCH_SITE=same-origin
HTTP_SEC_FETCH_MODE=navigate
HTTP_SEC_FETCH_USER=?1
HTTP_SEC_FETCH_DEST=document
HTTP_REFERER=http://localhost/envtest.html
HTTP_ACCEPT_ENCODING=gzip, deflate, br
HTTP_COOKIE=phpbb3_qtei6_k=; PHPSESSID=d7mvb47vlrd43160290ugec0n9; PHPSESSIDmycal=d7mvb47vlrd43160290ugec0n9mycal; phpbb3_qtei6_u=2; phpbb3_qtei6_sid=3961a5f7ff7cf89e8b34ab94a5559a7d
ALL_HTTP=HTTP_HOST: localhost
HTTP_CONNECTION: keep-alive
HTTP_SEC_CH_UA: "Brave";v="111", "Not(A:Brand";v="8", "Chromium";v="111"
HTTP_SEC_CH_UA_MOBILE: ?0
HTTP_SEC_CH_UA_PLATFORM: "macOS"
HTTP_UPGRADE_INSECURE_REQUESTS: 1
HTTP_USER_AGENT: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Safari/537.36
HTTP_ACCEPT: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8
HTTP_SEC_GPC: 1
HTTP_ACCEPT_LANGUAGE: en-US,en
HTTP_SEC_FETCH_SITE: same-origin
HTTP_SEC_FETCH_MODE: navigate
HTTP_SEC_FETCH_USER: ?1
HTTP_SEC_FETCH_DEST: document
HTTP_REFERER: http://localhost/envtest.html
HTTP_ACCEPT_ENCODING: gzip, deflate, br
HTTP_COOKIE: phpbb3_qtei6_k=; PHPSESSID=d7mvb47vlrd43160290ugec0n9; PHPSESSIDmycal=d7mvb47vlrd43160290ugec0n9mycal; phpbb3_qtei6_u=2; phpbb3_qtei6_sid=3961a5f7ff7cf89e8b34ab94a5559a7d

ALL_RAW=Host: localhost
Connection: keep-alive
sec-ch-ua: "Brave";v="111", "Not(A:Brand";v="8", "Chromium";v="111"
sec-ch-ua-mobile: ?0
sec-ch-ua-platform: "macOS"
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8
Sec-GPC: 1
Accept-Language: en-US,en
Sec-Fetch-Site: same-origin
Sec-Fetch-Mode: navigate
Sec-Fetch-User: ?1
Sec-Fetch-Dest: document
Referer: http://localhost/envtest.html
Accept-Encoding: gzip, deflate, br
Cookie: phpbb3_qtei6_k=; PHPSESSID=d7mvb47vlrd43160290ugec0n9; PHPSESSIDmycal=d7mvb47vlrd43160290ugec0n9mycal; phpbb3_qtei6_u=2; phpbb3_qtei6_sid=3961a5f7ff7cf89e8b34ab94a5559a7d

INSTANCE_ID=0
X_ABYSS_STATS_SERVER_TOTAL=4398
X_ABYSS_STATS_SERVER_ERROR=211
X_ABYSS_STATS_SERVER_HTML=656
X_ABYSS_STATS_SERVER_IMAGE=768
X_ABYSS_STATS_SERVER_NOTMODIFIED=884
X_ABYSS_STATS_SERVER_OUTPUT=30538689
X_ABYSS_STATS_SERVER_UPTIME=5640289
X_ABYSS_STATS_SERVER_CURRENT_UPTIME=677192
X_ABYSS_STATS_HOST_TOTAL=4398
X_ABYSS_STATS_HOST_ERROR=211
X_ABYSS_STATS_HOST_HTML=656
X_ABYSS_STATS_HOST_IMAGE=768
X_ABYSS_STATS_HOST_NOTMODIFIED=884
X_ABYSS_STATS_HOST_OUTPUT=30538689
X_ABYSS_STATS_HOST_UPTIME=5640127
X_ABYSS_STATS_HOST_CURRENT_UPTIME=677192
X_ABYSS_STATS_HOST_COMPRESS_TOTAL=1273
X_ABYSS_STATS_HOST_COMPRESS_OUTPUT=2968368
X_ABYSS_STATS_HOST_COMPRESS_ORIGINAL_OUTPUT=12760398
X_ABYSS_STATS_SERVER_COMPRESS_TOTAL=1938
X_ABYSS_STATS_SERVER_COMPRESS_OUTPUT=5098202
X_ABYSS_STATS_SERVER_COMPRESS_ORIGINAL_OUTPUT=22201933
HOME=/Users/user
LOGNAME=root
SHLVL=1
lvjbypge

lvjbypge1#

SQL字符串分隔符是单引号,而您提供的是双引号。此外,单引号可能会妨碍变量替换。
在这种情况下,您应该将stderr重定向到stdout以查看evtl. error输出。要检查var解析,请将“sqlite”与“cat”交换,并尽可能使用here-document而不是cmdline参数:

cat << .EndOfInput
bla bla bla
${sausageDog}
blub
.EndOfInput

这样,你就不必太在意转义引号之类的东西了。

相关问题