How to bring a date to the ping command

Source: Internet
Author: User
Tags count echo date

Linux:

While:;d o ping-c 1 172.16.128.36|awk '/ttl=/' |sed ' s/^/' date +%y-%m-%d\|%t '/'; sleep 1;done

See more highlights of this column: http://www.bianceng.cnhttp://www.bianceng.cn/Network/wgzs/

Execution results

2011-03-08|15:55:49 bytes from 172.16.128.6:icmp_seq=0 ttl=252 time=0 ms

2011-03-08|15:55:50 bytes from 172.16.128.6:icmp_seq=0 ttl=252 time=0 ms

2011-03-08|15:55:51 bytes from 172.16.128.6:icmp_seq=0 ttl=252 time=0 ms

2011-03-08|15:55:52 bytes from 172.16.128.6:icmp_seq=0 ttl=252 time=0 ms

Windows:

''

"Use method

'; cscript ping.vbs 192.168.1.1-t-L 1000

''

Dim args, flag, unsuccout

Args= ""

Otherout= ""

Flag=0

If WScript.Arguments.count = 0 Then

WScript.Echo "Usage:cscript Ping.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

Save into Tping.vbs

Executes the cscript tping.vbs under command

Output results

2005-9-14 12:02:01 Reply from 192.168.0.249:bytes=32 time<10ms ttl=64

2005-9-14 12:02:02 Reply from 192.168.0.249:bytes=32 time<10ms ttl=64

2005-9-14 12:02:03 Reply from 192.168.0.249:bytes=32 time<10ms ttl=64

2005-9-14 12:02:04 Reply from 192.168.0.249:bytes=32 time<10ms ttl=64

If you want to save for a long time, then redirect to the file >

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.