zoukankan      html  css  js  c++  java
  • windows下dos窗口实现持续ping显示时间保存至日志

    效果图

    右击新建 ping.bat 文件(ping为文件名称,随便起),内容如下:

    cscript ping.vbs  127.0.0.1 -t >log.txt

    127.0.0.1 修改为你自己的ip地址,log 为记录日志的文件名

    右击新建 ping.vbs 文件(ping为文件名称,随便起,但是需要与上方 csript xxx.vbs 对应),内容如下:

    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()
    'WScript.Echo  "原数据" & chr(9) & strLine
       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

    文件下载

    下载地址:https://files.cnblogs.com/files/niceyoo/ping.rar

  • 相关阅读:
    android数据恢复
    UVA 690 Pipeline Scheduling
    2017 国庆湖南 Day4
    2017 国庆湖南 Day5
    2017 国庆湖南 Day6
    2017国庆 清北学堂 北京综合强化班 Day1
    2017 国庆湖南Day2
    bzoj 2962 序列操作
    UVA 818 Cutting Chains
    UVA 211 The Domino Effect
  • 原文地址:https://www.cnblogs.com/niceyoo/p/11038696.html
Copyright © 2011-2022 走看看