[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
返回列表 发帖

求助批处理Ping完不通的IP地址找出对应的名字编号

求助 Ping完不通的IP地址找出对应的名字编号
  1. @echo on
  2. del D:\1\adb\63butong.txt
  3. del D:\1\adb\63tong.txt
  4. chcp 437
  5. goto:63
  6. set /p temp=:
  7. if /I "%temp%"=="62" goto :62
  8. if /I "%temp%"=="63" goto :63
  9. if /I "%temp%"=="64" goto :64
  10. if /I "%temp%"=="3" goto :3
  11. if /I "%temp%"=="4" goto :4
  12. if /I "%temp%"=="6" goto :6
  13. if /I "%temp%"=="7" goto :7
  14. if /I "%temp%"=="5" goto :5
  15. if /I "%temp%"=="226" goto :226
  16. if /I "%temp%"=="236" goto :236
  17. if /I "%temp%"=="230" goto :230
  18. if /I "%temp%"=="234" goto :234
  19. if /I "%temp%"=="235" goto :235
  20. if /I "%temp%"=="229" goto :229
  21. if /I "%temp%"=="228" goto :228
  22. if /I "%temp%"=="227" goto :227
  23. if /I "%temp%"=="231" goto :231
  24. if /I "%temp%"=="224" goto :224
  25. if /I "%temp%"=="225" goto :225
  26. if /I "%temp%"=="238" goto :238
  27. if /I "%temp%"=="r" goto :r
  28. :63
  29. setlocal enabledelayedexpansion
  30. for /f %%a in (a.txt) do (
  31. ping -n 1 %%a >pinglog.txt
  32. For /f "skip=2 tokens=4 delims=: " %%c In ('find "statistics" pinglog.txt') Do set IP=%%c
  33. For /f "skip=2 tokens=4,7,11 delims=,( " %%j In ('find "Lost" pinglog.txt') Do set Sent=%%j&set Received=%%k&set Lost=%%l
  34. For /f "skip=2 tokens=3,6,9 delims=, " %%m In ('find "Average" pinglog.txt') Do set Minimum=%%m&set Maximum=%%n&set Average=%%o
  35. For /f "tokens=3" %%y in ('find /c "Request timed out" pinglog.txt') do set Count=%%y
  36. if !Count! neq 0 echo  TIME OUT IPAddress=!IP! Sent=!Sent! Received=!Received! Lost=!Lost! Minimum=!Minimum! Maximum=!Maximum! Average=!Average >>d:\1\abd\123.txt
  37. findstr /c:"Destination" pinglog.txt && echo %date%%time% Unreachable IPAddress=!IP! Sent=!Sent! Received=!Received! Lost=!Lost!>>63butong.txt
  38. findstr /c:"Request" pinglog.txt && echo %date%%time% Unreachable IPAddress=!IP! Sent=!Sent! Received=!Received! Lost=!Lost!>>63butong.txt
  39. echo, !%%j! >>63butong.txt
  40. findstr /c:"TTL=" pinglog.txt && echo !IP! >>63tong.txt
  41. butong
  42. )
  43. pause
复制代码

TOP

[文本处理] ping地址并输出IP的对应目标名称。

我们单位的局域网包含有两百多个IP地址,每一个IP地址对应一个固定的目标名称,现在,我要编一个批处理命令,用PING去ping每一个IP地址,然后,ping不通的就用》输出到一个txt文件上,要求是不光输出IP地址,还要显示输出相对就的目标名称,比如11.102.203.77是一楼,11.102.203.77是大门!谢谢!各位老师指教!

  1. <#*,:&cls
  2. @echo off
  3. cd /d "%~dp0"
  4. powershell -NoProfile -ExecutionPolicy RemoteSigned -Command ". ([ScriptBlock]::Create((Get-Content -LiteralPath \"%~0\" -ReadCount 0 | Out-String ))) "
  5. pause
  6. exit /b
  7. #>
  8. $htIPs = @{
  9.   '192.168.82.1' = '网关'
  10.   '192.168.82.2' = 'PC1'
  11.   '192.168.82.3' = 'PC2'
  12.   '192.168.82.4' = 'PC3'
  13.   '192.168.82.5' = 'OPPO1'
  14. }
  15. Test-Connection -AsJob -ComputerName @($htIPs.Keys) -Count 1 | Wait-Job | Receive-Job | Where-Object { $_.StatusCode -ne 0 } | ForEach-Object {
  16.   '{0} {1}' -f @($_.Address, $htIPs[$_.Address])
  17. } | Set-Content -Path 'disconnected.txt'
复制代码
微信:flashercs
QQ:49908356

TOP

回复 3# flashercs


    谢谢大师!

TOP

学习了,谢谢。

TOP

返回列表