免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1919 | 回复: 6
打印 上一主题 下一主题

问题请教(shell+cgi+apache) [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2012-05-22 09:01 |只看该作者 |倒序浏览
我用shell脚本直接运行系统会自动排版
如:
PING xxx.xxx.xx.xx (192.168.xx.xx) 56(84) bytes of data.
64 bytes from xxx.xxx.xx.xx (192.168.xx.xx): icmp_seq=0 ttl=123 time=41.8 ms
64 bytes from xxx.xxx.xx.xx (192.168.xx.xx): icmp_seq=1 ttl=123 time=38.5 ms
64 bytes from xxx.xxx.xx.xx (192.168.xx.xx): icmp_seq=2 ttl=123 time=38.4 ms
64 bytes from xxx.xxx.xx.xx (192.168.xx.xx): icmp_seq=3 ttl=123 time=38.7 ms
64 bytes from xxx.xxx.xx.xx (192.168.xx.xx): icmp_seq=4 ttl=123 time=38.4 ms
64 bytes from xxx.xxx.xx.xx (192.168.xx.xx): icmp_seq=5 ttl=123 time=38.7 ms

但是在apache+cgi里运行结果:
PING  xxx.xxx.xx.xx (192.168.xx.xx):  56(84) bytes of data. 64 bytes from  xxx.xxx.xx.xx (192.168.xx.xx): icmp_seq=0 ttl=122 time=62.5 ms 64 bytes from  xxx.xxx.xx.xx (192.168.xx.xx): icmp_seq=1 ttl=122 time=41.4 ms 64 bytes from  xxx.xxx.xx.xx (192.168.xx.xx):  icmp_seq=2 ttl=122 time=38.6 ms From 192.168.*.***: icmp_seq=3 Redirect Network(New nexthop: 192.168.10.***) 64 bytes from  xxx.xxx.xx.xx (192.168.xx.xx): icmp_seq=3 ttl=122 time=38.5 ms From 192.168.10.***: icmp_seq=4 Redirect Network(New nexthop: 192.168.10.***) 64 bytes from  xxx.xxx.xx.xx (192.168.xx.xx): icmp_seq=4 ttl=122 time=38.4 ms 64 bytes from xxx.xxx.xx.xx (192.168.xx.xx): icmp_seq=5 ttl=122 time=38.4 ms ---  xxx.xxx.xx.xx (192.168.xx.xx):  ping statistics --- 6 packets transmitted, 6 received, 0% packet loss, time 5006ms rtt min/avg/max/mdev = 38.416/43.010/62.518/8.794 ms, pipe 2

请问有什么好方法吗,好像也不能添加换行符号(单独的文本文字可以换行,系统命令执行结果如何换行?)

论坛徽章:
0
2 [报告]
发表于 2012-05-22 09:24 |只看该作者
你是在浏览器里面显示的吗?每行后面加个 <br />

论坛徽章:
0
3 [报告]
发表于 2012-05-22 09:30 |只看该作者
回复 2# xiay_


    命令执行过程 请问怎么加???

单独的文字可以的。

论坛徽章:
15
2015年辞旧岁徽章
日期:2015-03-03 16:54:15双鱼座
日期:2015-01-15 17:29:44午马
日期:2015-01-06 17:06:51子鼠
日期:2014-11-24 10:11:13寅虎
日期:2014-08-18 07:10:55酉鸡
日期:2014-04-02 12:24:51双子座
日期:2014-04-02 12:19:44天秤座
日期:2014-03-17 11:43:36亥猪
日期:2014-03-13 08:13:51未羊
日期:2014-03-11 12:42:03白羊座
日期:2013-11-20 10:15:18CU大牛徽章
日期:2013-04-17 11:48:45
4 [报告]
发表于 2012-05-22 09:54 |只看该作者
没测试过啊。
  1. ping hostname |sed 's/$/ <br>/'
复制代码

论坛徽章:
0
5 [报告]
发表于 2012-05-22 10:13 |只看该作者
LZ是不是把ping的执行结果直接赋值给一个shell变量了?
如果是的话,在输出该变量时,用双引号括起来,试试看

论坛徽章:
8
摩羯座
日期:2014-11-26 18:59:452015亚冠之浦和红钻
日期:2015-06-23 19:10:532015亚冠之西悉尼流浪者
日期:2015-08-21 08:40:5815-16赛季CBA联赛之山东
日期:2016-01-31 18:25:0515-16赛季CBA联赛之四川
日期:2016-02-16 16:08:30程序设计版块每日发帖之星
日期:2016-06-29 06:20:002017金鸡报晓
日期:2017-01-10 15:19:5615-16赛季CBA联赛之佛山
日期:2017-02-27 20:41:19
6 [报告]
发表于 2012-05-22 10:41 |只看该作者
echo '<pre>'
ping xxx
echo '</pre>'

论坛徽章:
0
7 [报告]
发表于 2012-05-22 15:35 |只看该作者
回复 4# rdcwayx


    谢谢您,我知道这个命令 但是就是没想起来,还没做到 灵活运用!
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP