簡體   English   中英

以編程方式停止android adb ping並打印統計信息

[英]Stop android adb ping programmatically and print statistics

我正在嘗試發送x秒鍾的ping(而不是一定數量的ping)並收集結果。 我注意到,如果我安裝並運行“ ping www.google.com”並用CTRL + C停止它,則不會打印統計信息,但是如果我運行“ ping -c5 www.google.com”,則將打印統計信息。 有沒有一種方法可以發送ping命令,在指定的時間后使其超時,然后打印ping統計信息?

注意:我正在使用Java以編程方式發送此消息。

C:\Users\Field_Test>adb shell
shell@android:/ $ ping www.google.com
ping www.google.com
PING www.google.com (173.194.46.116) 56(84) bytes of data.
64 bytes from ord08s13-in-f20.1e100.net (173.194.46.116): icmp_seq=1 ttl=54 time
=55.7 ms
64 bytes from ord08s13-in-f20.1e100.net (173.194.46.116): icmp_seq=2 ttl=54 time
=70.9 ms
64 bytes from ord08s13-in-f20.1e100.net (173.194.46.116): icmp_seq=3 ttl=54 time
=60.8 ms
64 bytes from ord08s13-in-f20.1e100.net (173.194.46.116): icmp_seq=4 ttl=54 time
=71.1 ms
64 bytes from ord08s13-in-f20.1e100.net (173.194.46.116): icmp_seq=5 ttl=54 time
=69.8 ms
64 bytes from ord08s13-in-f20.1e100.net (173.194.46.116): icmp_seq=6 ttl=54 time
=72.0 ms
^C

nm,找到它。 “ -w#”將運行指定的時間並打印統計信息。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM