0
貓/usr/lib/cgi-bin/test00.cgi的cgi-bin,bash和格式化輸出
#!/bin/bash
echo "Content-type: text/html"
cat /tmp/file
結果是:
one two three four
如何格式輸出如bash腳本(與新隊)?
one
two
three
four
貓/usr/lib/cgi-bin/test00.cgi的cgi-bin,bash和格式化輸出
#!/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
您是否嘗試過'文本plain'的/不是'文/ html'? –
從哪裏出來'一二三四'?並且'echo'字符串在哪裏?Content-type:text/html' – Inian
@Inian OP正在編寫一個[CGI](https://stackoverflow.com/questions/2089271/what-is-common-gateway-interface- CGI)腳本。所以我假設OP指的是_a web browser_呈現最終的HTTP響應的方式。 'Context-type'是HTTP標頭的一部分,因此不能直接看到。其餘的顯然是'/ tmp/file'的內容。 –