I want to detect key pressed in my .cgi web page, but it does not work even I found the code in other web site.
My code is :
#!/bin/sh
#=================================================
# PATH defination
# ================================================
DEFAULT_CONFIG=/etc/default_path
. ${DEFAULT_CONFIG}
if [ -r $MAIN_CONFIG ]; then
. $MAIN_CONFIG
else
echo "$MAIN_CONFIG not found !!!"
exit 1
fi
#=================================================
# Get external script function
# ================================================
#getData()
#
# parameters: $1 : variable name
# $2 : the filename to be get from
#
# Return variable name: "getDataRtn" - return request of $1 value
#
# i.e. getData "LAN1_IFACE" $MAIN_CONFIG
# answer=$getDataRtn
#
if [ -r ${WWW_SCRIPTS_LIB_PATH}/getData.sh ]; then
. ${WWW_SCRIPTS_LIB_PATH}/getData.sh
else
echo "${WWW_SCRIPTS_LIB_PATH}/getData() not found !!!"
exit 1
fi
#=================================================
# Get display language
# ================================================
getData "LANGUAGE=" $MAIN_CONFIG
Language=$getDataRtn
. ${WWW_MSG_PATH}/${Language}/DCapture
. ${WWW_MSG_PATH}/${Language}/commsg
#=================================================
# Main
# ================================================
echo "Content-type: text/html"
echo "Pragma: no-cache"
echo ""
echo "<HTML><HEAD>"
echo "<meta http-equiv=content-type content=text/html; charset=UTF-8>"
echo "<TITLE>$msg010</TITLE>"
. ${WWW_SCRIPTS_LIB_PATH}/style-init.sh
echo "</HEAD>"
echo "<BODY>"
ShowSubLogo "$msg010"
if [ "$CONTENT_LENGTH" != "" ]; then
#if [ "$Stop" != "" ]; then
killall tcpdump
#ShowEndSucess "Capture Done!" "DCf_form"
#fi
fi
read -s -n 1 -p "Press any key to continue..."
echo "Test"
echo "<br> </br>"
echo "<br> </br>"
echo "<form name=DbC_form method=post action=DCapturefile.cgi>"
echo "<input name=Start value=\"$msg020\" type=submit>"
echo "<br> </br>"
echo "</form>"
echo "</BODY></HTML>"
The red word is what I found, but the result in the web page running is print Test,
that means: it skip the read operation?
So, is there has another way to detect pressing key down?
My purpose is :
Press any key to execute the shell script.
The whole process is:
Press "Start" button, and transfer to another .cgi web page.
The web page is do the shell script :
/fs1/tcpdump/tcpdump -c 20000 -s 1500 -w $filename &
and it works fine.
But I want to do another shell script when user want to stop capture tcpdump.
So, all the resolution I think are:
- Detect key pressing, and if key pressed, do killall tcpdump.
2.There is a button in the .cgi web(html code), click button, and execute the shell script: killall tcpdump .
But I do not know how to press a button to do shell script as well.
Or is there has the other way?
Any help appreciated.