2016-01-08 63 views
0

我想將用戶在簡單的HTML表單中提交的字符串(如下所示)傳遞給shell腳本。
到目前爲止我還沒有找到答案。我會很感激任何提示。通過CGI將字符串傳遞到shell腳本

<form method="post" action="http://example.com/cgi-bin/echo.sh"> 
<input type="text" name="Text" value=""><br> 
<input type="submit" value="Submit"> 
</form> 

而一個shell腳本應該打印它捕獲的值。

#!/bin/bash 
echo "Content-type: text/html" 
echo "" 
echo '<html>' 
echo '<head>' 
echo '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">' 
echo '<title>Echoing argument</title>' 
echo '</head>' 
echo '<body>' 
echo $1 
echo '</body>' 
echo '</html>' 

回答

0

This article幫助搞清楚了。 我必須在echo $1之前添加set $QUERY_STRING行。

+1

'echo「$ QUERY_STRING」''而不是'set $ QUERY_STRING; echo $ 1' –

+0

@thatotherguy,謝謝!好多了! – fieryvova

相關問題