- 论坛徽章:
- 0
|
如何在ping 命令结果前面加上时间日期!!!
- Dim args, flag, unsuccOut
- args=""
- otherout=""
- flag=0
- If WScript.Arguments.count = 0 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=0 to WScript.Arguments.count - 1
- 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()
- r=re.Test(strLine)
- If r Then
- WScript.Echo date & " "& time & chr(9) & strLine
- flag=1
- Else
- unsuccOut=unsuccOut & strLine
- End if
- Wend
- if flag = 0 then
- WScript.Echo unsuccOut
- 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 |
|