cgi-bin, bash 和格式化输出
cgi-bin, bash and formatting output
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
在这里您可以同时使用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
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
在这里您可以同时使用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