保持线浏览器使用bash CGI格式化 [英] Keep line formatting in browser with bash CGI

查看:178
本文介绍了保持线浏览器使用bash CGI格式化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用这个庆典CGI:

I'm using this bash CGI:

#!/usr/bin/sh
echo "Content-type: text/html"
echo ""
echo `ls -al`

和它产生的,即:

共有52 drwxrwxrwx。 2根根4096 2月2日18:34。 drwxr-XR-X。 8根
  根4096 2月2日17:58 .. -rw-R - R--。 1根根36310 2月2日17:45
  dds.jpg -rw-RW-RW-。 1用户用户50 2月2日18:03 dds_panel.htm
  -rwxrwxrwx。 1用户的用户460 2月2日18:34测试cgi.cgi

total 52 drwxrwxrwx. 2 root root 4096 Feb 2 18:34 . drwxr-xr-x. 8 root root 4096 Feb 2 17:58 .. -rw-r--r--. 1 root root 36310 Feb 2 17:45 dds.jpg -rw-rw-rw-. 1 user user 50 Feb 2 18:03 dds_panel.htm -rwxrwxrwx. 1 user user 460 Feb 2 18:34 test-cgi.cgi

在一个终端,他们出现在每个整齐地在一行但在浏览器中出现的所有在同一行。什么是保持格式的最好方法?

In a terminal they appear each neatly on a single line but in the browser they appear all on the same line. What's the best way to keep the formatting?

推荐答案

如果您不需要任何HTML格式,只需更改内容类型为文本/纯

If you do not need any html formatting, simply change the content-type to text/plain.

如果您需要HTML格式输出应该包含一个完整的HTML页面。在这种情况下环绕您的输出< pre> ,以取代换行符< BR> 或转换您在像列表或表格输出。

If you need html formatting your output should contain a complete html page. In this case surround your output with <pre>, replace newlines with <br> or convert your output in something like a list or table.

这篇关于保持线浏览器使用bash CGI格式化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆