cgi-bin,bash和格式输出

时间:2017-09-07 10:42:57

标签: bash apache cgi-bin

cat /usr/lib/cgi-bin/test00.cgi

#!/bin/bash
echo "Content-type: text/html"
cat /tmp/file

结果是:

one two three four

格式输出如何像bash脚本(带换行符)?

one
two
three
four

1 个答案:

答案 0 :(得分:1)

您可以在这里使用html和UNIX命令

#!/bin/bash

echo Content-type: text/html
echo ""

/bin/cat << EOM
<HTML>
<HEAD><TITLE>File Output: /tmp/file </TITLE>
</HEAD>
<BODY bgcolor="#cccccc" text="#000000">
<HR SIZE=5>
<H1>File Output: /tmp/file </H1>
<HR SIZE=5>
<P>
<SMALL>
<PRE>
EOM

/bin/cat /tmp/file

CAT << EOM
</PRE>
</SMALL>
<P>
</BODY>
</HTML>
EOM