[英]Bash-Shell script show source code, not html
It's weird that my shell script in website show the whole source code, not the html that I want. 我网站上的shell脚本显示了整个源代码,而不是我想要的html,这很奇怪。 My script is:
我的脚本是:
#!/bin/sh
echo "Content-type: text/html"
echo ""
cat << EOF
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<title>test</title>
<link type="text/css" href="../jquery/css/redmond/jquery-ui-custom.min.css" rel="stylesheet">
<script type="text/javascript" src="../jquery/js/jquery.min.js"></script>
<script type="text/javascript" src="../jquery/js/jquery-ui-custom.min.js"></script>
<script type="text/javascript">
//<![CDATA[
if(verifiedUser == "")
window.top.location.href = "/";
//]]>
</script>
</head>
<body>
<table align="center">
<tr><td align="right">Product Name</td><td align="left">
</td></tr>
<tr><td align="right">Hardware Version</td><td align="left">
</td></tr>
<tr><td align="right">Firmware Version</td><td align="left">
</td></tr>
</table>
</body>
</html>
EOF
and what the .cgi file show is just that code! .cgi文件显示的只是该代码! My cgi file is in the same directory of the html files, because the main directory is in /mnt, so not put in /home/www/cgi-bin/ as usual.
我的cgi文件与html文件位于同一目录中,因为主目录位于/ mnt中,所以不像往常那样放在/ home / www / cgi-bin /中。
What's the reasonable problem can cause this situation? 有什么合理的问题可以导致这种情况?
Any advice appreciated! 任何建议表示赞赏!
AFAIK, the separator between header section & the html data should be a blank line in CRLF
format . AFAIK,标头部分和html数据之间的分隔符应为
CRLF
格式的空白行。
Try this: 尝试这个:
echo -e "Content-type: text/html\r"
echo -e "\r"
cat << 'EOF'
---remaining HTML data---
EOF
Note: I have also changed cat << EOF
to cat << 'EOF'
to prevent any variable expansion. 注意:我也将
cat << EOF
更改为cat << 'EOF'
以防止任何变量扩展。 Revert it if variable/command expansion is needed. 如果需要变量/命令扩展,请将其还原。
@Barmar has the right idea - Your server is very likely not configured to run those files, but rather send the file directly to the client. @Barmar是正确的想法-您的服务器很可能没有配置为运行那些文件,而是直接将文件发送给客户端。 So it's a configuration issue, not a programming one.
因此,这是一个配置问题,而不是编程问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.