免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
楼主: jhgzzq

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

论坛徽章:
0
发表于 2005-09-20 10:40 |显示全部楼层

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

原帖由 "b.s.d" 发表:

我的是2003

将Windows脚本宿主升级到5.6试试

论坛徽章:
0
发表于 2005-09-20 12:29 |显示全部楼层

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

[quote]原帖由 "slash001"][/quote 发表:

unix下C编程也会,老弟全才啊, 就差Java的了
你让俺看到了中国软件的希望啊,哈哈

论坛徽章:
0
发表于 2005-09-20 13:23 |显示全部楼层

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

呵呵,我不是做开发的,就会简单的瞎写点,见笑了

论坛徽章:
0
发表于 2005-09-20 13:50 |显示全部楼层

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

呵呵,做管理的都会瞎写点就很难得了

论坛徽章:
0
发表于 2005-09-20 15:25 |显示全部楼层

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

如果是在 Linux 下面,可以这样

  1. # while :;do ping -c 1 172.17.39.251|awk '/ttl=/'|sed "s/^/`date +%Y-%m-%d\|%T` /";sleep 1;done
复制代码



显示效果如下
[root@PT_LINUX boot]# while :;do ping -c 1 172.17.39.251|awk '/ttl=/'|sed "s/^/`date +%Y-%m-%d\|%T` /";sleep 1;done
2005-09-20|15:24:40 64 bytes from 172.17.39.251: icmp_seq=0 ttl=128 time=0.240 ms
2005-09-20|15:24:41 64 bytes from 172.17.39.251: icmp_seq=0 ttl=128 time=0.235 ms
2005-09-20|15:24:42 64 bytes from 172.17.39.251: icmp_seq=0 ttl=128 time=0.220 ms
2005-09-20|15:24:43 64 bytes from 172.17.39.251: icmp_seq=0 ttl=128 time=0.224 ms
2005-09-20|15:24:45 64 bytes from 172.17.39.251: icmp_seq=0 ttl=128 time=0.211 ms
2005-09-20|15:24:46 64 bytes from 172.17.39.251: icmp_seq=0 ttl=128 time=0.211 ms
2005-09-20|15:24:47 64 bytes from 172.17.39.251: icmp_seq=0 ttl=128 time=0.222 ms
2005-09-20|15:24:48 64 bytes from 172.17.39.251: icmp_seq=0 ttl=128 time=0.221 ms
2005-09-20|15:24:49 64 bytes from 172.17.39.251: icmp_seq=0 ttl=128 time=0.222 ms

[root@PT_LINUX boot]#

论坛徽章:
0
发表于 2005-09-26 08:48 |显示全部楼层

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

我想请问一下为什么在我的机子上这个命令不行呢

论坛徽章:
0
发表于 2005-09-26 23:27 |显示全部楼层

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

[quote]原帖由 "slash001"][/quote 发表:


cool!

论坛徽章:
1
2015元宵节徽章
日期:2015-03-06 15:50:39
发表于 2005-09-28 22:09 |显示全部楼层

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

哪位高手可以将tping.vbs更改一下,可以自己设定ip和一些参数?
比如cscript tping.vbs 192.168.1.1 -t -l 1000
那就完美了。

论坛徽章:
0
发表于 2005-09-30 10:01 |显示全部楼层

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


  1. Dim args, flag, unsuccOut
  2. args=""
  3. otherout=""
  4. flag=0

  5. If WScript.Arguments.count = 0 Then
  6.         WScript.Echo "Usage: cscript tping.vbs [-t] [-a] [-n count] [-l size] [-f] [-i TTL] [-v TOS]"
  7.         WScript.Echo "                         [-s count] [[-j host-list] | [-k host-list]]"
  8.         WScript.Echo "                         [-r count] [-w timeout] destination-list"
  9.         wscript.quit
  10. End if

  11. For i=0 to WScript.Arguments.count - 1
  12.         args=args & " " & WScript.Arguments(i)
  13. Next

  14. Set shell = WScript.CreateObject("WScript.Shell")
  15. Set re=New RegExp
  16. re.Pattern="^Reply|^Request"
  17. Set myping=shell.Exec("ping" & args)

  18. while Not myping.StdOut.AtEndOfStream
  19.    strLine=myping.StdOut.ReadLine()
  20.    r=re.Test(strLine)
  21.    If r Then
  22.         WScript.Echo date & " "& time & chr(9) & strLine
  23.         flag=1
  24.    Else
  25.         unsuccOut=unsuccOut & strLine
  26.    End if
  27. Wend

  28. if flag = 0 then
  29.         WScript.Echo unsuccOut
  30. end if
复制代码


E:\>;cscript tping.vbs 192.168.0.249 -t -l 1000
Microsoft (R) Windows Script Host Version 5.6
版权所有(C) Microsoft Corporation 1996-2001。保留所有权利。

2005-9-30 10:03:29      Reply from 192.168.0.249: bytes=1000 time<10ms TTL=64
2005-9-30 10:03:30      Reply from 192.168.0.249: bytes=1000 time<10ms TTL=64
2005-9-30 10:03:31      Reply from 192.168.0.249: bytes=1000 time<10ms TTL=64
2005-9-30 10:03:32      Reply from 192.168.0.249: bytes=1000 time<10ms TTL=64
2005-9-30 10:03:33      Reply from 192.168.0.249: bytes=1000 time<10ms TTL=64
2005-9-30 10:03:34      Reply from 192.168.0.249: bytes=1000 time<10ms TTL=64
2005-9-30 10:03:35      Reply from 192.168.0.249: bytes=1000 time<10ms TTL=64
2005-9-30 10:03:36      Reply from 192.168.0.249: bytes=1000 time<10ms TTL=64

论坛徽章:
0
发表于 2005-10-08 16:13 |显示全部楼层

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

   
zzzzzz
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

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

清除 Cookies - ChinaUnix - Archiver - WAP - TOP