0

致力于自动制作故障排除指南,因此我作为技术人员可以按..start ..这是我坚持的步骤之一,对我如何制作批处理文件有任何帮助吗?

Check procedure: 

1. Ping 10.70.222.62 -t
Look for any dropped packets.  > or = 1%, send at least 100 pings. 

2.Check the subnet mask 
3.Check the default gateway 
4.Check NIC configuration.  If more than 1 NIC is installed then only one should have the gateway set. 
If all OK, then network is OK. 

我不是一个网络人,所以当它说检查子网掩码之类的东西时,我不确定那是什么,或者我在检查它是为了什么。网卡配置也可能很难用批处理文件检查?谢谢。

发现了一些可能有帮助的更多信息..

Subnet Mask  255.255.254.0  
Default Gateway  10.72.170.1  

我确实更改了一些数字,但我可以在需要时将它们改回代码中。

到目前为止第1步..

ping -n 100 x.x.x.x  | find "TTL"
if not errorlevel 1 set error=FAILED
if errorlevel 1 set error=PASSED
echo Result: %error%

唯一的问题是它显示了所有的 ping,无论如何让它不显示 ping?

第 2 步我想你必须做一个 ipconfig 并找到结果?但不确定如何.. 与第 3 步相同

第4步我不知道它在说什么......

4

2 回答 2

1

for 命令将帮助您隐藏 ping。按照斯蒂芬的回答,这就是你想要的:

第 1,2,3 步:-

    @echo off
    echo Checking ping...
    set state=FAILED
    for /f "tokens=5,7" %%a in ('ping x.x.x.x -n 100') do (
    if "%%a"=="Received" if "%%b"=="100," set state=PASSED
    )
    echo Getting IP configuration...
    ipconfig > stats.txt
    find "Subnet Mask" stats.txt
    find "Gateway" stats.txt
    del stats.txt
    pause

第4步:-我真的不知道如何批量执行...尝试使用第三方软件。

于 2013-03-30T10:37:37.753 回答
0

第 1 步:寻找“(0% loss)”而不是“TTL”会更容易,因为找到 TTL 可能意味着,您尝试了 100 次,只有一两个响应会返回 PASSED。(不要搜索“0%”,因为这样也会找到 10% 20%...)

ping -n 100 x.x.x.x >nul |find "(0%"

第 2,3 步:获取配置文件ipconfig >stats.txt

find "Subnet Mask" stats.txt 用and 得到想要的值find "Gateway" stats.txt

第4步并不简单,我想把它留给其他人

于 2013-03-29T08:43:25.507 回答