【windows下】:

ping.vbs

Dim args, flag, unsuccOut
args=""
otherout=""
flag= If WScript.Arguments.count = Then
WScript.Echo "Usage: cscript tping.vbs [-t] [-a] [-n count] [-l size] [-f] [-i TTL] [-v TOS]"
WScript.Echo " [-s count] [[-j host-list] | [-k host-list]]"
WScript.Echo " [-r count] [-w timeout] destination-list"
wscript.quit
End if For i= to WScript.Arguments.count -
args=args & " " & WScript.Arguments(i)
Next Set shell = WScript.CreateObject("WScript.Shell")
Set re=New RegExp
re.Pattern="^Reply|^Request|^来自|^请求" Set myping=shell.Exec("ping" & args) while Not myping.StdOut.AtEndOfStream
strLine=myping.StdOut.ReadLine()
'WScript.Echo "原数据" & chr(9) & strLine
r=re.Test(strLine)
If r Then
WScript.Echo date & " "& time & chr() & strLine
flag=
Else
unsuccOut=unsuccOut & strLine
End if
Wend if flag = then
WScript.Echo unsuccOut
end if

ping.bat

cscript ping.vbs 10.8.115.127 -n  >ping_log.txt

执行ping.bat即可

效果如下:

Microsoft (R) Windows Script Host Version 5.812
版权所有(C) Microsoft Corporation。保留所有权利。

2018/11/19 14:17:13 来自 10.8.115.115 的回复: 字节=32 时间<1ms TTL=200
2018/11/19 14:17:14 来自 10.8.115.115 的回复: 字节=32 时间<1ms TTL=200
2018/11/19 14:17:15 来自 10.8.115.115 的回复: 字节=32 时间<1ms TTL=200
2018/11/19 14:17:16 来自 10.8.115.115 的回复: 字节=32 时间=1ms TTL=200

【linux下】

ping $1 |while read line;do echo `date`$line;done >> ping_test.log

效果:

root@/root/chen#ping 10.8.210.101 |while read line;do echo `date`$line;done
Mon Nov 19 14:23:42 CST 2018PING 10.8.210.101 (10.8.210.101) 56(84) bytes of data.
Mon Nov 19 14:23:42 CST 201864 bytes from 10.8.210.101: icmp_seq=1 ttl=64 time=0.257 ms
Mon Nov 19 14:23:43 CST 201864 bytes from 10.8.210.101: icmp_seq=2 ttl=64 time=0.163 ms
Mon Nov 19 14:23:44 CST 201864 bytes from 10.8.210.101: icmp_seq=3 ttl=64 time=0.141 ms
Mon Nov 19 14:23:45 CST 201864 bytes from 10.8.210.101: icmp_seq=4 ttl=64 time=0.160 ms
Mon Nov 19 14:23:46 CST 201864 bytes from 10.8.210.101: icmp_seq=5 ttl=64 time=0.148 ms

最新文章

  1. sublime Text 的安装、破解、汉化、使用
  2. js中奇特的for循环写法
  3. 起因:dell超级密码算号器 1F66
  4. nodeJs开发app.js解析
  5. 逐行返回http响应的内容
  6. EasyUI DataGrid定制默认属性名称
  7. 找出二叉树中和为n的路径
  8. 【.NET】Repeater控件简单的数据绑定(有bool,日期,序号)
  9. VS2010安装OpenGL
  10. Java TimSort算法 源码 笔记
  11. iFace Chain [ 爱妃链 ] 或将凭借人脸密钥技术成为安全领域最大的赢家
  12. 如何解决代码中if…else 过多的问题
  13. Python装饰器举例分析
  14. golang自定义struct字段标签
  15. 【转】九大排序算法-C语言实现及详解
  16. vim 自动注释
  17. centos7之iptables与firewalld
  18. Oracle PL/SQL学习之基础篇(2)--例外
  19. underscore arrays
  20. vim—多行注释、取消多行注释

热门文章

  1. SQL学习 存储过程&amp;DUAL表
  2. js vue 请求
  3. Git 几个常用操作
  4. python glob模块使用笔记(更新)
  5. 14. Encryption tools (加密工具 8个)
  6. 在mysql配置文件修改sql_mode或sql-mode 怎么办?
  7. [JAVA]字节流拷贝文件
  8. @cacheevict 清除多个key
  9. AllocateHWnd SetTimer API
  10. C#模拟Https请求时出现 基础连接已经关闭 未能为 SSLTLS 安全通道建立信任关系