- 论坛徽章:
- 0
|
如何在ping 命令结果前面加上时间日期!!!
- \r\nDim args, flag, unsuccOut\r\nargs=\"\"\r\notherout=\"\"\r\nflag=0\r\n\r\nIf WScript.Arguments.count = 0 Then\r\n WScript.Echo \"Usage: cscript tping.vbs [-t] [-a] [-n count] [-l size] [-f] [-i TTL] [-v TOS]\"\r\n WScript.Echo \" [-s count] [[-j host-list] | [-k host-list]]\"\r\n WScript.Echo \" [-r count] [-w timeout] destination-list\"\r\n wscript.quit\r\nEnd if\r\n\r\nFor i=0 to WScript.Arguments.count - 1\r\n args=args & \" \" & WScript.Arguments(i)\r\nNext\r\n\r\nSet shell = WScript.CreateObject(\"WScript.Shell\") \r\nSet re=New RegExp \r\nre.Pattern=\"^Reply|^Request\" \r\nSet myping=shell.Exec(\"ping\" & args)\r\n\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 flag=1\r\n Else\r\n unsuccOut=unsuccOut & strLine\r\n End if \r\nWend\r\n\r\nif flag = 0 then\r\n WScript.Echo unsuccOut\r\nend if\r\n
复制代码 \r\n\r\nE:\\>;cscript tping.vbs 192.168.0.249 -t -l 1000\r\nMicrosoft (R) Windows Script Host Version 5.6\r\n版权所有(C) Microsoft Corporation 1996-2001。保留所有权利。\r\n\r\n2005-9-30 10:03:29 Reply from 192.168.0.249: bytes=1000 time<10ms TTL=64\r\n2005-9-30 10:03:30 Reply from 192.168.0.249: bytes=1000 time<10ms TTL=64\r\n2005-9-30 10:03:31 Reply from 192.168.0.249: bytes=1000 time<10ms TTL=64\r\n2005-9-30 10:03:32 Reply from 192.168.0.249: bytes=1000 time<10ms TTL=64\r\n2005-9-30 10:03:33 Reply from 192.168.0.249: bytes=1000 time<10ms TTL=64\r\n2005-9-30 10:03:34 Reply from 192.168.0.249: bytes=1000 time<10ms TTL=64\r\n2005-9-30 10:03:35 Reply from 192.168.0.249: bytes=1000 time<10ms TTL=64\r\n2005-9-30 10:03:36 Reply from 192.168.0.249: bytes=1000 time<10ms TTL=64 |
|