|
saiyy
新手上路
积分 16
发帖 6
注册 2007-11-28
状态 离线
|
『楼 主』:
如何修改以下文本内容?
具体情况,ping了大量网站把内容写入了一个文本中,
如何得到简单明了的结果,如下,当然越简单越好:
尝试用了for做修改~没有理想的结果~~
Quote: | Ping statistics for 64.233.189.104:
Packets: Sent = 10, Received = 10, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 106ms, Maximum = 112ms, Average = 109ms |
|
|
|
2007-12-2 00:41 |
|
|
lxmxn
版主
积分 11386
发帖 4938
注册 2006-7-23
状态 离线
|
|
2007-12-2 09:54 |
|
|
saiyy
新手上路
积分 16
发帖 6
注册 2007-11-28
状态 离线
|
『第
3 楼』:
只需要得到ping的结果,就是只要得到以下这些数据即可![IP、丢包率、最大、最小值、平均值]
Quote: | Ping statistics for 64.233.189.104:
Lost = 0 (0% loss),
Minimum = 106ms, Maximum = 112ms, Average = 109ms |
|
|
|
2007-12-4 15:12 |
|
|
lxmxn
版主
积分 11386
发帖 4938
注册 2006-7-23
状态 离线
|
『第
4 楼』:
这样就可以了吧?
ping www.baidu.com 2>nul| findstr /v "^Reply"
|
|
2007-12-4 16:00 |
|
|
saiyy
新手上路
积分 16
发帖 6
注册 2007-11-28
状态 离线
|
『第
5 楼』:
小弟对DOS批处理不太了解~~请指点
只要如下的结果 希望给个完整的办法!谢谢!
Quote: | Pinging a.a.a.a with 32 bytes of data:
Ping statistics for a.a.a.a:
Packets: Sent = 1, Received = 1, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 24ms, Maximum = 24ms, Average = 24ms
Pinging b.b.b.b with 32 bytes of data:
Ping statistics for b.b.b.b:
Packets: Sent = 1, Received = 1, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 24ms, Maximum = 24ms, Average = 24ms
…………
Pinging x.x.x.x with 32 bytes of data:
Ping statistics for x.x.x.x:
Packets: Sent = 1, Received = 1, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 24ms, Maximum = 24ms, Average = 24ms |
|
|
|
2007-12-4 17:27 |
|
|
lxmxn
版主
积分 11386
发帖 4938
注册 2006-7-23
状态 离线
|
『第
6 楼』:
To saiyy:
用Perl写了一个脚本,首先要把所有ping命令的结果存到pingresult.txt文件中,可以用这个命令:
for /f "delims=" %a in (domain.txt) do @ping %a >> pingresult.txt ,然后用下面的Perl脚本,即可得到你要的数据:
# use perl script to get uesful informations from the text file pingresult.txt
# code by lxmxn @ www.cn-dos.net/forum
#C:/perl/bin/perl
use strict;
use warnings;
my($fd);
open($fd,"<pingresult.txt")||die "Can't open pingresult.txt:$!\n";
undef($/);
my $textcontext=<$fd>;
while($textcontext=~m/Pinging (.*?) \[([0-9.]+)\].*?, (Lost = \d+ \(\d+% loss\)).*?(Minimum.*?\n)/sg){
print "*" x 20 . "\n$1 [$2] \n$3\n$4\n";
}
close($fd);
此帖被 +1 点积分 点击查看详情 评分人:【 saiyy 】 | 分数: +1 | 时间:2007-12-5 11:23 |
|
|
|
2007-12-4 23:33 |
|
|
saiyy
新手上路
积分 16
发帖 6
注册 2007-11-28
状态 离线
|
『第
7 楼』:
谢谢你的指点~~其实我的初衷是想提取IP、最大、最小、平均值、丢包率写进一个xls表格或者数据库里~~看来这么做不容易实现~~手工添加相当麻烦~期望高手能有好的方案!谢谢斑主的帮助!
PS:遗憾的是对Perl也不怎么了解~~需要学习的东西太多了!!
[ Last edited by saiyy on 2007-12-5 at 11:23 AM ]
|
|
2007-12-5 10:58 |
|