免费注册 查看新帖 |

Chinaunix

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

如何在ping 命令结果前面加上时间日期!!! [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2005-09-09 13:01 |只看该作者 |倒序浏览
我现在打算测试一个网络是否正常.要观察几天.打算用ping的方式检查.\r\n\r\n但只有下面的显示:\r\n\r\nPinging 10.111.23.1 with 32 bytes of data:\r\n\r\nReply from 10.111.23.1 : bytes=32 time=2ms TTL=255\r\nReply from 10.111.23.1 : bytes=32 time=2ms TTL=255\r\nReply from 10.111.23.1 : bytes=32 time=1ms TTL=255\r\n\r\n无法定位是在哪个时间里出现的.我想在前面加上时间如:\r\n\r\nPinging 10.111.23.1 with 32 bytes of data:\r\n\r\n2005-09-09 00:00:00 Reply from 10.111.23.1 : bytes=32 time=2ms TTL=255\r\n2005-09-09 00:00:01 Reply from 10.111.23.1 : bytes=32 time=2ms TTL=255\r\n2005-09-09 00:00:02 Reply from 10.111.23.1 : bytes=32 time=1ms TTL=255\r\n\r\n哪位大侠知道bat的批处理该如何实现?

论坛徽章:
0
2 [报告]
发表于 2005-09-09 13:31 |只看该作者

如何在ping 命令结果前面加上时间日期!!!

我有一个笨办法\r\nwhile [ 1 ];do\r\ndate;ping ip -c 1\r\ndone

论坛徽章:
0
3 [报告]
发表于 2005-09-09 13:55 |只看该作者

如何在ping 命令结果前面加上时间日期!!!

while [ 1 ];do \r\ndate;ping ip -c 1 \r\ndone\r\n\r\n这个写在bat里是无法执行的吧.能否具体点呢

论坛徽章:
0
4 [报告]
发表于 2005-09-09 16:39 |只看该作者

如何在ping 命令结果前面加上时间日期!!!

怎么没有人回复哟.....

论坛徽章:
0
5 [报告]
发表于 2005-09-09 16:46 |只看该作者

如何在ping 命令结果前面加上时间日期!!!

\r\nwhile [ 1 ];do\r\ndate;ping ip -c 1\r\ndone\r\n\r\n这个写在bat里是无法执行的吧.能否具体点呢\r\n
\r\n我以为你是linux系统。\r\n很久没碰dos了。帮不了你。

论坛徽章:
0
6 [报告]
发表于 2005-09-13 17:45 |只看该作者

如何在ping 命令结果前面加上时间日期!!!

@echo off\r\n:START\r\ndate/t >> aa.txt\r\ntime/t >> aa.txt\r\nping 10.111.23.1 -n 10 >>aa.txt\r\ngoto START\r\n\r\n稍微变通的方法,呵呵。\n\n[ 本帖最后由 AmoyOriole 于 2006-4-4 08:57 编辑 ]

论坛徽章:
0
7 [报告]
发表于 2005-09-13 19:10 |只看该作者

如何在ping 命令结果前面加上时间日期!!!

谢谢:AmoyOriole\r\n\r\n不过这种格式打印出来的结果时间怎么一直不变呢?是语句哪里有问题?\r\n\r\n2005-09-13 星期二 \r\n19:09\r\n\r\nPinging 134.230.55.1 with 32 bytes of data:\r\n\r\nReply from 134.230.55.1: bytes=32 time=2ms TTL=255\r\nReply from 134.230.55.1: bytes=32 time=2ms TTL=255\r\nReply from 134.230.55.1: bytes=32 time=2ms TTL=255\r\n\r\nPing statistics for 134.230.55.1:\r\n    Packets: Sent = 3, Received = 3, Lost = 0 (0% loss),\r\nApproximate round trip times in milli-seconds:\r\n    Minimum = 2ms, Maximum = 2ms, Average = 2ms\r\n2005-09-13 星期二 \r\n19:09\r\n\r\nPinging 134.230.55.1 with 32 bytes of data:\r\n\r\nReply from 134.230.55.1: bytes=32 time=2ms TTL=255\r\nReply from 134.230.55.1: bytes=32 time=3ms TTL=255\r\nReply from 134.230.55.1: bytes=32 time=2ms TTL=255\r\n\r\nPing statistics for 134.230.55.1:\r\n    Packets: Sent = 3, Received = 3, Lost = 0 (0% loss),\r\nApproximate round trip times in milli-seconds:\r\n    Minimum = 2ms, Maximum = 3ms, Average = 2ms\r\n2005-09-13 星期二 \r\n19:09\r\n\r\nPinging 134.230.55.1 with 32 bytes of data:\r\n\r\nReply from 134.230.55.1: bytes=32 time=2ms TTL=255\r\n\r\nPing statistics for 134.230.55.1:\r\n    Packets: Sent = 1, Received = 1, Lost = 0 (0% loss),\r\nApproximate round trip times in milli-seconds:\r\n    Minimum = 2ms, Maximum = 2ms, Average = 2ms

论坛徽章:
0
8 [报告]
发表于 2005-09-14 10:09 |只看该作者

如何在ping 命令结果前面加上时间日期!!!

time/t只精确到分钟。\r\n改成ehco. |time >;>; aa.txt 就可以了。

论坛徽章:
0
9 [报告]
发表于 2005-09-14 10:42 |只看该作者

如何在ping 命令结果前面加上时间日期!!!

谢谢了,我又学到了一些东西!

论坛徽章:
0
10 [报告]
发表于 2005-09-14 12:03 |只看该作者

如何在ping 命令结果前面加上时间日期!!!

  1. \r\nSet shell = WScript.CreateObject(\"WScript.Shell\")\r\nSet re=New RegExp\r\nre.Pattern = \"^Reply|^Request\"\r\nSet myping=shell.Exec(\"ping 192.168.0.249\")\r\nwhile Not myping.StdOut.AtEndOfStream\r\n        strLine = myping.StdOut.ReadLine()\r\n        r=re.Test(strLine)\r\n        If r Then\r\n                WScript.Echo date & \" \"& time & chr(9) & strLine\r\n        End if\r\nWend\r\n
复制代码
\r\n\r\n保存成tping.vbs\r\n在command下执行cscript tping.vbs\r\n\r\n输出结果\r\n2005-9-14 12:02:01      Reply from 192.168.0.249: bytes=32 time<10ms TTL=64\r\n2005-9-14 12:02:02      Reply from 192.168.0.249: bytes=32 time<10ms TTL=64\r\n2005-9-14 12:02:03      Reply from 192.168.0.249: bytes=32 time<10ms TTL=64\r\n2005-9-14 12:02:04      Reply from 192.168.0.249: bytes=32 time<10ms TTL=64
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

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

清除 Cookies - ChinaUnix - Archiver - WAP - TOP