帮忙看下我这边批处理错在什么地方
@EchoOff:pecho%date%%time%ping172.18.26.21-n3ping172.18.26.33-n3ping172.18.26.37-n3pi...
@Echo Off
:p
echo %date%%time%
ping 172.18.26.21 -n 3
ping 172.18.26.33 -n 3
ping 172.18.26.37 -n 3
ping 172.18.26.38 -n 3
ping 172.18.26.39 -n 3
ping 172.18.26.43 -n 3
ping 172.18.26.46 -n 3
ping 172.18.26.48 -n 3
ping 172.18.26.50 -n 3
ping 172.18.26.52 -n 3
ping 172.18.26.54 -n 3
ping 172.18.26.55 -n 3
ping 172.18.26.56 -n 3
ping 172.18.26.58 -n 3
ping 172.18.26.59 -n 3
set aa=1
for /f "delims=:" %%1 in ('findstr "timed out" 1.txt') do set aa=0
if %aa%==1 set /A ok=%ok%+1
if %aa%==0 set /A no=%no%+1
goto haha
:end
goto haha
:end
echo 连接数 %ok%
echo 未连接数 %no%
pause
无法生成1.txt 展开
:p
echo %date%%time%
ping 172.18.26.21 -n 3
ping 172.18.26.33 -n 3
ping 172.18.26.37 -n 3
ping 172.18.26.38 -n 3
ping 172.18.26.39 -n 3
ping 172.18.26.43 -n 3
ping 172.18.26.46 -n 3
ping 172.18.26.48 -n 3
ping 172.18.26.50 -n 3
ping 172.18.26.52 -n 3
ping 172.18.26.54 -n 3
ping 172.18.26.55 -n 3
ping 172.18.26.56 -n 3
ping 172.18.26.58 -n 3
ping 172.18.26.59 -n 3
set aa=1
for /f "delims=:" %%1 in ('findstr "timed out" 1.txt') do set aa=0
if %aa%==1 set /A ok=%ok%+1
if %aa%==0 set /A no=%no%+1
goto haha
:end
goto haha
:end
echo 连接数 %ok%
echo 未连接数 %no%
pause
无法生成1.txt 展开
1个回答
展开全部
每行的ping语句前加>>1.txt 比如 >>1.txt ping 172.18.26.21 -n 3 才会有1.txt
但是后面的代码也有问题,如果你要1.txt只是过渡一下最后显示统计数量,另写个参考:
@echo off
set ips=21 33 37 38 39 43
set/a ok=no=0
for %%i in (%ips%)do (
ping -n 1 172.18.26.%%i>nul&&set/a ok+=1||set/p no+=1
)
echo 连接数 %ok%
echo 未连接数%no%
pause
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询