免费注册 查看新帖 |

Chinaunix

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

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

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2005-09-09 13:01 |只看该作者 |倒序浏览
我现在打算测试一个网络是否正常.要观察几天.打算用ping的方式检查.

但只有下面的显示:

Pinging 10.111.23.1 with 32 bytes of data:

Reply from 10.111.23.1 : bytes=32 time=2ms TTL=255
Reply from 10.111.23.1 : bytes=32 time=2ms TTL=255
Reply from 10.111.23.1 : bytes=32 time=1ms TTL=255

无法定位是在哪个时间里出现的.我想在前面加上时间如:

Pinging 10.111.23.1 with 32 bytes of data:

2005-09-09 00:00:00 Reply from 10.111.23.1 : bytes=32 time=2ms TTL=255
2005-09-09 00:00:01 Reply from 10.111.23.1 : bytes=32 time=2ms TTL=255
2005-09-09 00:00:02 Reply from 10.111.23.1 : bytes=32 time=1ms TTL=255

哪位大侠知道bat的批处理该如何实现?

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

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

我有一个笨办法
while [ 1 ];do
date;ping ip -c 1
done

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

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

while [ 1 ];do
date;ping ip -c 1
done

这个写在bat里是无法执行的吧.能否具体点呢

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

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

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

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

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

while [ 1 ];do
date;ping ip -c 1
done

这个写在bat里是无法执行的吧.能否具体点呢

我以为你是linux系统。
很久没碰dos了。帮不了你。

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

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

@echo off
:START
date/t >> aa.txt
time/t >> aa.txt
ping 10.111.23.1 -n 10 >>aa.txt
goto START

稍微变通的方法,呵呵。

[ 本帖最后由 AmoyOriole 于 2006-4-4 08:57 编辑 ]

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

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

谢谢:AmoyOriole

不过这种格式打印出来的结果时间怎么一直不变呢?是语句哪里有问题?

2005-09-13 星期二
19:09

Pinging 134.230.55.1 with 32 bytes of data:

Reply from 134.230.55.1: bytes=32 time=2ms TTL=255
Reply from 134.230.55.1: bytes=32 time=2ms TTL=255
Reply from 134.230.55.1: bytes=32 time=2ms TTL=255

Ping statistics for 134.230.55.1:
    Packets: Sent = 3, Received = 3, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 2ms, Maximum = 2ms, Average = 2ms
2005-09-13 星期二
19:09

Pinging 134.230.55.1 with 32 bytes of data:

Reply from 134.230.55.1: bytes=32 time=2ms TTL=255
Reply from 134.230.55.1: bytes=32 time=3ms TTL=255
Reply from 134.230.55.1: bytes=32 time=2ms TTL=255

Ping statistics for 134.230.55.1:
    Packets: Sent = 3, Received = 3, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 2ms, Maximum = 3ms, Average = 2ms
2005-09-13 星期二
19:09

Pinging 134.230.55.1 with 32 bytes of data:

Reply from 134.230.55.1: bytes=32 time=2ms TTL=255

Ping statistics for 134.230.55.1:
    Packets: Sent = 1, Received = 1, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 2ms, Maximum = 2ms, Average = 2ms

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

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

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

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

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

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

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

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


  1. Set shell = WScript.CreateObject("WScript.Shell")
  2. Set re=New RegExp
  3. re.Pattern = "^Reply|^Request"
  4. Set myping=shell.Exec("ping 192.168.0.249")
  5. while Not myping.StdOut.AtEndOfStream
  6.         strLine = myping.StdOut.ReadLine()
  7.         r=re.Test(strLine)
  8.         If r Then
  9.                 WScript.Echo date & " "& time & chr(9) & strLine
  10.         End if
  11. Wend
复制代码


保存成tping.vbs
在command下执行cscript tping.vbs

输出结果
2005-9-14 12:02:01      Reply from 192.168.0.249: bytes=32 time<10ms TTL=64
2005-9-14 12:02:02      Reply from 192.168.0.249: bytes=32 time<10ms TTL=64
2005-9-14 12:02:03      Reply from 192.168.0.249: bytes=32 time<10ms TTL=64
2005-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