在ksh / html中检索我的CGI上的query_string

问题描述 投票:0回答:1

我的CGI中有这个ksh脚本:

SERV_LINUX=$(cat /xxx/xxx/xxx/xxx/xxx/xxx/foo.txt | awk -F';' '{print $2}' | sort | uniq)

DATE_Linux=$(cat /xxx/xxx/xxx/xxx/xxx/xxx/foo.txt | awk -F';' '{print $3}' | sort | uniq)

echo "<form action="LINUX_GNU.ksh" method="post">"
echo "<select name="SERV">"
echo "$SERV_LINUX" | while read SERV_LINUX; do
echo " <option value="$SERV_LINUX">$SERV_LINUX</option>"
done
echo "</select>"

echo "<select name="DATE_Linux">"
echo "$DATE_Linux" | while read DATE_Linux; do
echo " <option value="$DATE_Linux">$DATE_Linux</option>"
done
echo "</select>"

echo "<input type="submit" value="Select">"
echo "</form>"

echo "</div>"

此脚本创建一个下拉菜单,允许您选择服务器。在第二页上,如果我输入以下内容:

read a 
echo $a 

我能够像这样检索查询字符串:

SERV=my_serv&DATE_Linux=2019-10 

我想知道是否可以仅通过按钮来做相同的事情?我的意思是,如果我的下拉菜单中有4个选项,那么我想创建4个按钮,例如:

SERV_LINUX=$(cat /xxx/xxx/xxx/xxx/xxx/xxx/foo.txt | awk -F';' '{print $2}' | sort | uniq)

echo "<form action="test.ksh" method="post">"
echo "$SERV_LINUX" | while read SERV_LINUX; do
echo "<input type="submit" value="$SERV_LINUX">"
done
echo "</select>"
echo "</form>"

但是当我尝试这样做时,我没有结果……您认为有可能吗?您有任何想法吗?

谢谢! :)

bash cgi query-string ksh
1个回答
0
投票

您到处都缺少转义序列。您需要纠正它。这对我有用:

SERV_LINUX=$(echo -e "server1\nserver2\nserver3" | sort | uniq)

echo "<form action=\"test.ksh\" method=\"post\">"
while read SERV_LINUX; do
    echo "<input type=\"submit\" value=\"$SERV_LINUX\">"
done <<< "$SERV_LINUX"
echo "</select></form>"

让我知道是否有帮助。

© www.soinside.com 2019 - 2024. All rights reserved.